-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Keep fileid when restoring version, using stream copy #15486
Conversation
Note that this is broken on OC 8.0.3 as well, we might want a backport @karlitschek (even if it's for 8.0.4, depending on severity) |
Fixes #15468 |
looks good 👍 Backport is fine but only for 8.0.4 |
I've tested #15468 in this branch and it works. |
Yes, this is expected, in case you want to re-switch back to the version you had before. |
In OC 7 after restoring oldest version there is no creation of a new version. |
Hmmm strange, thanks for the check. In OC 7 that would probably happen too if the version is restored to external storage... as a side effect |
As this is not going into 8.0.3 I'll have a look later during the bugfix phase. |
|
What happens if we don't have enough space to duplicate the file? |
The same as on OC 7: stuff will likely break... Before restoring the version, there is existing code that will backup the current file (as an extra version) through copying, and then proceed to restore the selected version. |
b0af09f
to
7b53672
Compare
I changed the implementation: now it's doing the rename/copy on storage level to avoid touching the cache, which will also keep the file id. Please review/retest @icewind1991 @SergioBertolinSG @schiesbn @nickvergessen |
|
||
if ($result !== false) { | ||
$storage1->unlink($internalPath1); | ||
$storage1->getCache()->remove($internalPath1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It turns out it also works without this line. I'll remove it once Jenkins is done (to avoid confusing it)
Maybe getVersions() is doing a rescan internally.
Please review (sorry, forgot to set the label to "to review") |
@SergioBertolinSG can you retest this ? |
@PVince81 I have tested #15468 in |
@SergioBertolinSG I did fix the problem with the extra version. Did you "git pull" this branch ? |
I tested it in a new install, checking out the branch for first time. I have to say it doesn't happen always, but many times. |
Are you able to identify the exact cases in which it happens ? |
No not external storages. |
Erasing? That's the expiration code in action. The expiration is only triggered when you do an action on the file. You were talking about additional versions ? |
Maybe one way to test it is to look at the "data/$user/files_versions" folder and look at the timestamps "filename.txt.v123456" (the number is the timestamp).
So at this point, no new version is created. |
@PVince81 Yes, that's the behaviour. After restoring last version of the dropdown having five versions of a file, in the "data/$user/files_versions" folder there is the backup of the filename.txt, and another version which was the third one. The rest were erased. So this is the expected behaviour of versions? |
$target = $storage2->fopen($internalPath2, 'w'); | ||
// FIXME: might need to use part file to avoid concurrent writes | ||
// (this would be an issue anyway when renaming/restoring cross-storage) | ||
list(, $result) = \OC_Helper::streamCopy($source, $target); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use moveFromStorage
now that's in master?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you saying I could also get rid of the $storage1 === $storage2
case that way ?
I'll have a try later.
ac9c889
to
972e189
Compare
A new inspection was created. |
Rebased onto master. @icewind1991 I replaced streamCopy with moveFromStorage. Please rereview @SergioBertolinSG @icewind1991 @schiesbn |
Refer to this link for build results (access rights to CI server needed): |
Tested and works. File ID keeps stable 👍 |
Keep fileid when restoring version, using stream copy
Backport in #16019 |
…fileid Keep fileid when restoring version, using stream copy
Always stream copy when restoring version
This is a workaround to make it possible to keep the file id when restoring a file. Please note that a stream copy would happen anyway when restoring cross-storage.
Please review @icewind1991 @SergioBertolinSG @nickvergessen @MorrisJobke @DeepDiver1975