Skip to content

[WIP] Stable file ids when moving between storages - #13312

Closed
PVince81 wants to merge 1 commit into
masterfrom
files-stablefileid
Closed

PVince81 wants to merge 1 commit into
masterfrom
files-stablefileid

Conversation

@PVince81

Copy link
Copy Markdown
Contributor

In the spirit of "test first" this PR contains failing tests to make file ids stable.

Ref #13310

@DeepDiver1975 @icewind1991 FYI

@PVince81 PVince81 mentioned this pull request Jan 13, 2015
3 tasks done
@DeepDiver1975 DeepDiver1975 added this to the 8.0-current milestone Jan 13, 2015
@ghost

ghost commented Jan 13, 2015

Copy link
Copy Markdown

Refer to this link for build results (access rights to CI server needed):
https://ci.owncloud.org//job/pull-request-analyser-ng-simple/6555/

Build result: FAILURE

[...truncated 16 lines...]Fetching upstream changes from https://github.com/owncloud/core.gitusing GIT_SSH to set credentials using .gitcredentials to set credentials > git config --local credential.helper store --file=/tmp/git1005879802005631867.credentials # timeout=10 > git -c core.askpass=true fetch --tags --progress https://github.com/owncloud/core.git +refs/pull/:refs/remotes/origin/pr/ > git config --local --remove-section credential # timeout=10 > git rev-parse origin/pr/13312/merge^{commit} # timeout=10 > git branch -a --contains eb75b5771f7fc9abcec58c63bc711bec9000ccc3 # timeout=10 > git rev-parse remotes/origin/pr/13312/merge^{commit} # timeout=10Checking out Revision eb75b5771f7fc9abcec58c63bc711bec9000ccc3 (origin/pr/13312/merge) > git config core.sparsecheckout # timeout=10 > git checkout -f eb75b5771f7fc9abcec58c63bc711bec9000ccc3First time build. Skipping changelog. > git remote # timeout=10 > git submodule init # timeout=10 > git submodule sync # timeout=10 > git config --get remote.origin.url # timeout=10 > git submodule update --init --recursiveTriggering pull-request-analyser-ng-simple » SLAVEpull-request-analyser-ng-simple » SLAVE completed with result FAILUREStarted calculate disk usage of buildFinished Calculation of disk usage of build in 0 secondsStarted calculate disk usage of workspaceFinished Calculation of disk usage of workspace in 0 seconds
💣 Test FAILed. 💣

@scrutinizer-notifier

Copy link
Copy Markdown

The inspection completed: 2 new issues, 3 updated code elements

@MorrisJobke

Copy link
Copy Markdown
Contributor

You rock!

@MorrisJobke

Copy link
Copy Markdown
Contributor

8.0 o.O

@PVince81 PVince81 changed the title [WIP] Stable file ids [WIP] Stable file ids when moving between storages Jan 13, 2015
@PVince81

Copy link
Copy Markdown
Contributor Author

It sounds quite tricky and is likely to break stuff, so very likely to be 8.1.

Writing down some ideas here:

Currently when moving a file between storages, it's a "rename" operation ($view->rename())
That operation detects that it's cross-storage, so for a folder it will call $view->copy() instead, and if that succeeded it will delete the source (https://github.com/owncloud/core/blob/master/lib/private/files/view.php#L504).
If it's a file, it will do two fopens and stream copy the file to the target, then delete the source.

In the case of copy(), the tricky part is making sure that not only the copied folder keeps its file id but also all children.

Approach 1): prevent any file cache update until completion of the operation. At the end, find all source entries for the source files, then update the "storage" column to be the new storage, update "path", "path_hash" and "parent" to match the new location.
If the change isn't atomic, there will be a small time window where the cache is partially update, could cause side effects if race conditions. Maybe the old entries could be "disabled" somehow (if we had a "invisible" flag) until they are all updated, and then reenabled.

Approach 2): same as approach 1), but the files + cache are updated one by one instead of all at the end of the copy. This means we'll need a special implementation of "copy" which is specific to this case (separate from the read $view->copy())

Approach 3): gather fileid of cache entries that match the file to be copied, then delete them. Perform the copy and update the new cache entries (that appears because of the copy) and change their fileid to the old ones.
Drawback is that there is a short time window where these files might become visible until their file ids get changed.

So far I prefer approach 2)

@PVince81

Copy link
Copy Markdown
Contributor Author

I forgot about this branch...

Merged it into this PR that has a partial fix: #13385

@PVince81 PVince81 closed this Jan 15, 2015
@PVince81
PVince81 deleted the files-stablefileid branch January 15, 2015 13:07
@lock lock Bot locked as resolved and limited conversation to collaborators Aug 14, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants