Skip to content
This repository has been archived by the owner on Jun 21, 2024. It is now read-only.

Changes regarding FS #38

Open
jvillafanez opened this issue Oct 11, 2018 · 1 comment
Open

Changes regarding FS #38

jvillafanez opened this issue Oct 11, 2018 · 1 comment

Comments

@jvillafanez
Copy link
Member

Implement custom FS access

Add a new class OCA\DataExporter\Utilities\FSAccess. This class will be a wrapper around standard PHP FS operations. There are a couple of extra features to include:

  • Change the base root folder of all operations. This mean that all operations will be made inside that target folder. For example, if the root folder is changed to "/tmp/my/root", the real target of a "/myfile.txt" will be "/tmp/my/root/myfile.txt"
  • No operations will be made until the base root folder is set
  • The base root folder will be set only once. Changing it won't be possible.

Note that it's expected to wrap only the operations we need, and / or provide enhanced operations (mainly for copying files around).

In addition, the symfony's Filesystem class will be removed because of problems with big files. Our FSAccess class will replace it.

Usage expectations

Neither importers nor exporters will have a direct dependency on this class.

For importers:

  • The import method signature will be changed to (need to check more options):

    public function import(AbstractModel $modelToImport, FSAccess $fs);
    

    It's expected that the caller of the root importer has properly set the base root folder before calling the import method. In case of import dependencies, the FSAccess object will be passed around.

    Note that the one needing to access to the FS might be quite down in the dependency tree, and the one setting the base root folder should be one of the commands.

For exporters:

  • The extract method signature will be changed to:
    public function extract(AbstractModel $parentModel, FSAccess $fs);
    
    This will allow to extractors to write or copy files if needed.
@IljaN
Copy link
Member

IljaN commented Oct 11, 2018

In addition, the symfony's Filesystem class will be removed because of problems with big files.

Which problems?

The property of the symfony thing I like most is that you can operate on nested paths e.g dump_file("foo/bar/hello.txt") and it will implicitly create the whole path.

Another option would be to just checkin the symfony Filesystem component and modify it to our needs as it is only a single file.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants