Skip to content

properly lock the target file on dav upload when not using part files - #9473

Merged
MorrisJobke merged 1 commit into
masterfrom
dav-upload-no-partfile-lock
Jun 11, 2018
Merged

properly lock the target file on dav upload when not using part files#9473
MorrisJobke merged 1 commit into
masterfrom
dav-upload-no-partfile-lock

Conversation

@icewind1991

Copy link
Copy Markdown
Member

While non-partfile storages don't have the file corruption problem on current read/writes (which is why I left this until now) not locking the target file during write can still lead to an inconsistent filecache state because the scanner is not being blocked.

@icewind1991icewind1991 added the 3. to review Waiting for reviews label May 14, 2018
@icewind1991icewind1991 added this to the Nextcloud 14 milestone May 14, 2018
throw new FileLocked($e->getMessage(), $e->getCode(), $e);
}
throw new FileLocked($e->getMessage(), $e->getCode(), $e);
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

No need for two ifs ;)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why? IMO it makes sense to split it. 🤔

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

fixed

@icewind1991
icewind1991force-pushed the dav-upload-no-partfile-lock branch from 8b854ee to 891460aCompareMay 15, 2018 12:00
@codecov

codecovBot commented May 15, 2018

Copy link
Copy Markdown

Codecov Report

Merging #9473 into master will decrease coverage by 20.65%.
The diff coverage is 0%.

@@ Coverage Diff @@## master #9473 +/- ##
=============================================
- Coverage 51.92% 31.27% -20.66% + Complexity 25769 25746 -23 
=============================================
Files 1635 1641 +6 Lines 95434 96518 +1084 Branches 1308 1393 +85 =============================================
- Hits 49557 30182 -19375 - Misses 45877 66336 +20459
Impacted FilesCoverage ΔComplexity Δ
apps/dav/lib/Connector/Sabre/File.php1.5% <0%> (-71.29%)99 <0> (-1)
apps/files_trashbin/lib/Command/Expire.php0% <0%> (-100%)3% <0%> (ø)
apps/dav/lib/Connector/Sabre/Server.php0% <0%> (-100%)1% <0%> (ø)
apps/user_ldap/lib/Migration/UUIDFixUser.php0% <0%> (-100%)1% <0%> (ø)
...yBuilder/FunctionBuilder/SqliteFunctionBuilder.php0% <0%> (-100%)1% <0%> (ø)
lib/private/Files/Mount/CacheMountProvider.php0% <0%> (-100%)4% <0%> (ø)
...ivate/Files/Cache/Wrapper/CachePermissionsMask.php0% <0%> (-100%)3% <0%> (ø)
lib/private/DB/SQLiteSessionInit.php0% <0%> (-100%)4% <0%> (ø)
lib/private/Files/Cache/Wrapper/JailPropagator.php0% <0%> (-100%)1% <0%> (ø)
...s/dav/lib/Connector/Sabre/Exception/FileLocked.php0% <0%> (-100%)3% <0%> (ø)
... and 450 more

@rullzerrullzer left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Makes sense!

@MorrisJobke

Copy link
Copy Markdown
Member

Unit tests fail. :/

$partStorage->unlink($internalPartPath);
if ($needsPartFile) {
if ($view) {
$this->emitPreHooks($exists);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

You ignore the result here now. So if the prehook returns false you should probably also fail right?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

See the unit tests, which fail now due to this.

@MorrisJobkeMorrisJobke left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

See unit tests and @rullzer's comment.

@MorrisJobkeMorrisJobke added 2. developing Work in progress and removed 3. to review Waiting for reviews labels Jun 11, 2018
Signed-off-by: Robin Appelman <robin@icewind.nl>
@icewind1991
icewind1991force-pushed the dav-upload-no-partfile-lock branch from 891460a to f017f43CompareJune 11, 2018 13:27
@icewind1991

Copy link
Copy Markdown
MemberAuthor

Fixed the unit test

@MorrisJobke
MorrisJobke merged commit 61fa284 into masterJun 11, 2018
@MorrisJobke
MorrisJobke deleted the dav-upload-no-partfile-lock branch June 11, 2018 14:54
@MorrisJobkeMorrisJobke added 3. to review Waiting for reviews backport-request and removed 2. developing Work in progress labels Jun 11, 2018
@MorrisJobke

Copy link
Copy Markdown
Member

@icewind1991 Does a backport to 13 makes sense or should we skip it?

@icewind1991

Copy link
Copy Markdown
MemberAuthor

backport makes sense imo

@MorrisJobke

Copy link
Copy Markdown
Member

@icewind1991 Could you prepare the PR?

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3. to reviewWaiting for reviews

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@icewind1991@MorrisJobke@rullzer