Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add file sync task #225

Closed
wants to merge 1 commit into from

Conversation

bergice
Copy link
Contributor

@bergice bergice commented Mar 18, 2019

This task is intended to fix up the filesystem/db in version 4.

It will remove invalid db entries and create db entries for assets that are currently missing db entries.

@bergice bergice force-pushed the pulls/1/file-sync-task branch 2 times, most recently from 3ecb5d6 to 5dce718 Compare March 19, 2019 00:33
Copy link
Contributor

@maxime-rainville maxime-rainville left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just did a high level code review. Didn't try running the code locally.

My main concern is that I think we should rely on the native FlySystem implementation we have in the Asset Store rather than rely on native PHP function. I would rather that part be fixed before spending more time testing it locally.

Also, a point to note is that some of the work I'm doing for the SS44 permalink job will probably help some of the things you are doing. I'm created generic classes that will be splitting up the URLs.

src/Dev/Tasks/FilesystemSyncTask.php Outdated Show resolved Hide resolved
src/Dev/Tasks/FilesystemSyncTask.php Outdated Show resolved Hide resolved
src/Dev/Tasks/FilesystemSyncTask.php Show resolved Hide resolved
src/Dev/Tasks/FilesystemSyncTask.php Outdated Show resolved Hide resolved
src/File.php Outdated Show resolved Hide resolved
src/FilesystemSyncTaskHelper.php Show resolved Hide resolved
src/FilesystemSyncTaskHelper.php Outdated Show resolved Hide resolved
src/FilesystemSyncTaskHelper.php Outdated Show resolved Hide resolved
src/FilesystemSyncTaskHelper.php Outdated Show resolved Hide resolved
src/FilesystemSyncTaskHelper.php Outdated Show resolved Hide resolved
src/File.php Outdated Show resolved Hide resolved
src/FilesystemSyncTaskHelper.php Outdated Show resolved Hide resolved
src/FilesystemSyncTaskHelper.php Outdated Show resolved Hide resolved
src/FilesystemSyncTaskHelper.php Outdated Show resolved Hide resolved
src/Flysystem/AssetAdapter.php Outdated Show resolved Hide resolved
src/Flysystem/AssetAdapter.php Outdated Show resolved Hide resolved
src/Flysystem/AssetAdapter.php Outdated Show resolved Hide resolved
src/Flysystem/FlysystemAssetStore.php Show resolved Hide resolved
tests/php/FilesystemSyncTaskTest.php Outdated Show resolved Hide resolved
Copy link
Contributor

@maxime-rainville maxime-rainville left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just did a deeper code review this time. There's still a lot of native file system code used, maybe confirm that there's no easy equivalent to flysystem for those.

The unit test looks very light. It's not testing with legacy_flenames and keep_archive_assets flags. I'll have a go at running it for real this afternoon.

src/Dev/Tasks/FilesystemSyncTask.php Show resolved Hide resolved
src/FilesystemSyncTaskHelper.php Outdated Show resolved Hide resolved
src/FilesystemSyncTaskHelper.php Show resolved Hide resolved
src/FilesystemSyncTaskHelper.php Show resolved Hide resolved
src/FilesystemSyncTaskHelper.php Outdated Show resolved Hide resolved
src/Flysystem/AssetAdapter.php Show resolved Hide resolved
src/Flysystem/AssetAdapter.php Show resolved Hide resolved
src/Flysystem/AssetAdapter.php Show resolved Hide resolved
src/Flysystem/FlysystemAssetStore.php Show resolved Hide resolved
src/Flysystem/FlysystemAssetStore.php Show resolved Hide resolved
This task is intended to fix up the filesystem/db in version 4.

It will remove invalid db entries and create db entries for assets that are currently missing db entries.
@bergice bergice force-pushed the pulls/1/file-sync-task branch from a6bd68a to 9fde7c9 Compare April 24, 2019 03:16
@bergice
Copy link
Contributor Author

bergice commented Apr 24, 2019

Just did a deeper code review this time. There's still a lot of native file system code used, maybe confirm that there's no easy equivalent to flysystem for those.

The unit test looks very light. It's not testing with legacy_flenames and keep_archive_assets flags. I'll have a go at running it for real this afternoon.

I've added a couple of more tests for this now.

Looks like the namespaces for permalinks needs to be fixed up though:

There was 1 error:

1) SilverStripe\Assets\Tests\FilesystemSyncTaskTest::testSyncKeepArchivedAssets
SilverStripe\Core\Injector\InjectorNotFoundException: ReflectionException: Class SilverStripe\Assets\FilenameParsing\FileResolutionStrategy.public does not exist in /var/www/mysite/www/vendor/silverstripe/framework/src/Core/Injector/InjectionCreator.php:17

@sminnee
Copy link
Member

sminnee commented May 29, 2019

I'm somewhat concerned about reintroducing this feature. We dropped it in the SS4 filesystem implementation because it was difficult to make robust and so caused follow on issues.

  • If you're looking to update the database to re-list files that were previously uploaded to SilverStripe but the database records have been deleted, you risk data corruption. One example of why you might want to do this is if you're looking to restore filesystem assets but not the database. The source of corruption is that the IDs of the File records will be different, and so any other data objects that reference those files is going to be wrong. It would be more honest to say "if you want to restore assets you probably have to restore a database too".

  • If you're looking to update the database to include files that were added to the assets/ folder out-of-band, I guess you're implementing a bulk upload feature. If that's the goal I question whether this is the best way of achieving this, especially for users who don't have FTP access to their servers.

So I'd ask the question: what problem are we trying to solve by re-adding this feature, and is this the best solution to the problem?

@sminnee
Copy link
Member

sminnee commented May 29, 2019

If the goal is to bulk-add new assets to a locally-running project, something like this might be safer, simpler, and more useful:

vendor/bin/import-assets ~/Downloads/stuff-from-the-customer ./Uploads/StuffFromTheCustomer

Which would add the files to the filesystem underneath a root folder ./Uploads/StuffFromTheCustomer

@chillu
Copy link
Member

chillu commented May 29, 2019

Commented on the card: #175 (comment)

@emteknetnz
Copy link
Member

This pull request hasn't had any activity for a while. Are you going to be doing further work on it, or would you prefer to close it now?

@maxime-rainville
Copy link
Contributor

I think we decided to drop this approach in the end. I don't think there's anything that can be salvage from this PR.

@maxime-rainville maxime-rainville deleted the pulls/1/file-sync-task branch September 2, 2020 01:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants