Skip to content

When calling file_put_contents clear the checksum - #24098

Merged
DeepDiver1975 merged 1 commit into
masterfrom
fix_23782
Apr 20, 2016
Merged

DeepDiver1975 merged 1 commit into
masterfrom
fix_23782

Conversation

@rullzer

@rullzer rullzer commented Apr 19, 2016 •

Copy link
Copy Markdown
Contributor

Fixes #23782 and #23783

If a file is changed we should reset the checksum.

  • Unit test added

To test:

  • Upload a file with checksum
    curl -u admin:admin http://localhost/master/remote.php/webdav/foo.txt -X PUT -T foo.txt -H "OC-Checksum: foobar"
  • Check the file cache. This file should have the checksum foobar
  • Download the file the OC-Checksum header should be set
  • Now edit the file in the texteditor and close it
  • Check the file cache. This file should have an empty checksum
  • Download the file the OC-Checksum header should not be set

Test 2:

  • Upload a file with checksum
    curl -u admin:admin http://localhost/master/remote.php/webdav/foo.txt -X PUT -T foo.txt -H "OC-Checksum: foobar"
  • Check the file cache. This file should have the checksum foobar
  • Download the file the OC-Checksum header should be set
  • Now edit the file directly on disk
  • Run ./occ files:scan admin
  • Check the file cache. This file should have an empty checksum
  • Download the file the OC-Checksum header should not be set

CC: @PVince81 @nickvergessen @MorrisJobke @dragotin

Comment thread lib/private/files/cache/updater.php Outdated
}
$this->correctParentStorageMtime($path);
if ($data['mimetype'] !== 'httpd/unix-directory') {
$this->clearChecksum($path);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

okay, I guess there is no easy way to integrate this change in one of the existing database calls.

@icewind1991 or is there a better moment ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Well it gets kind of messy trying to cram this into the scan call I think

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think it would make sense in general to clear the checksum in the scanner if it detects a change

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@icewind1991 This will likely be needed too for the other issue #23783 but would it also cover the text editor / file_put_contents issue too ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

scanFile indeed might be a good place...

Fixes #23782 and #23783

If the file scanner detects a changed file we clear the checksum while
we update the cache.

* Unit test added
@rullzer

rullzer commented Apr 19, 2016

Copy link
Copy Markdown
Contributor Author

Moved the check to the scanFile. Patch is simpler and cleaner.

@PVince81 @icewind1991 please have another look.

@icewind1991

Copy link
Copy Markdown
Contributor

Code looks good 👍

@rullzer

rullzer commented Apr 20, 2016

Copy link
Copy Markdown
Contributor Author

@karlitschek we should backport this to 9.0.2

@karlitschek

Copy link
Copy Markdown
Contributor

great. fix makes sense. please backport to stable9

@PVince81

Copy link
Copy Markdown
Contributor
  • TEST: text editor save clears checksum
  • TEST: occ files:scan with unchanged file leaves checksum alone
  • TEST: occ files:scan when file was changed directly on disk properly resets checksum

@PVince81

Copy link
Copy Markdown
Contributor
  • TEST: file changed remotely on SFTP ext storage, GET the file directly => checksum properly cleared

Looks good 👍

@PVince81

Copy link
Copy Markdown
Contributor

@rullzer can you prepare the backport PR ?

@rullzer

rullzer commented Apr 20, 2016

Copy link
Copy Markdown
Contributor Author

Backport in #24129

@DeepDiver1975
DeepDiver1975 merged commit cdcabbd into master Apr 20, 2016
@DeepDiver1975
DeepDiver1975 deleted the fix_23782 branch April 20, 2016 18:37
@lock

lock Bot commented Aug 6, 2019

Copy link
Copy Markdown

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock Bot locked as resolved and limited conversation to collaborators Aug 6, 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.

TextEditor: Checksum not invalidated on file change

6 participants