Skip to content

VerifyChecksum: Ignore files which are in filecache but not in the storage - #31430

Merged
DeepDiver1975 merged 2 commits into
masterfrom
verfiy_checksum_fixes
Aug 16, 2018
Merged

DeepDiver1975 merged 2 commits into
masterfrom
verfiy_checksum_fixes

Conversation

@IljaN

@IljaN IljaN commented May 14, 2018 •

Copy link
Copy Markdown
Contributor

Description

The verifier currently produces false-positives for files which are in filecache but not on the storage.

Related Issue

https://github.com/owncloud/enterprise/issues/2518

How Has This Been Tested?

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@IljaN IljaN added this to the development milestone May 14, 2018
@IljaN IljaN self-assigned this May 14, 2018
@patrickjahns

Copy link
Copy Markdown
Contributor

Shouldn't this require a normal occ file:scan then?

@IljaN
IljaN force-pushed the verfiy_checksum_fixes branch from 8ba6784 to 9540d6d Compare May 15, 2018 14:04
@codecov

codecov Bot commented May 15, 2018 •

Copy link
Copy Markdown

Codecov Report

Merging #31430 into master will increase coverage by 0.02%.
The diff coverage is 81.25%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master   #31430      +/-   ##
============================================
+ Coverage     64.01%   64.03%   +0.02%     
- Complexity    18564    18575      +11     
============================================
  Files          1171     1171              
  Lines         69851    69864      +13     
  Branches       1267     1267              
============================================
+ Hits          44714    44737      +23     
+ Misses        24767    24757      -10     
  Partials        370      370
Flag Coverage Δ Complexity Δ
#javascript 52.84% <ø> (ø) 0 <ø> (ø) ⬇️
#phpunit 65.31% <81.25%> (+0.02%) 18575 <3> (+11) ⬆️
Impacted Files Coverage Δ Complexity Δ
apps/files/lib/Command/VerifyChecksums.php 96.38% <81.25%> (+7.81%) 37 <3> (+11) ⬆️
lib/private/Files/Storage/Wrapper/Availability.php 50.64% <0%> (+1.29%) 80% <0%> (ø) ⬇️
lib/private/Files/Node/Node.php 88.23% <0%> (+1.47%) 62% <0%> (ø) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8ed910d...4f9fefe. Read the comment docs.

@PVince81 PVince81 left a comment

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.

one major issue with instance of check and a few minor ones

$owner = $node->getOwner()->getUID();
$storage = $node->getStorage();

if ($storage instanceof ISharedStorage || $storage instanceof FailedStorage) {

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.

$storage->instanceOfStorage(ISharedStorage::class) because of storage wrappers... please closely follow how the Util\Scanner does it

}

if (!self::fileExistsOnDisk($node)) {
$output->writeln("Skipping $owner/$path => File is in file-cache but doesn`t exist on storage/disk", OutputInterface::VERBOSITY_VERBOSE);

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.

use apostrophe and not backtick for "doesn't"

make sure to replace every other occurrence if any

an alternative is to use "does not"

* @return bool
*/
private static function fileExistsOnDisk(Node $node) {
$statResult = $node->stat();

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 see we don't have a method ->exists() on the node, ok.

Now I wonder what happens if the file happens to not be readable due to messed up permissions. Maybe also check $node->isReadable() ?

@IljaN
IljaN force-pushed the verfiy_checksum_fixes branch from 504eec9 to a3b0a8d Compare May 18, 2018 14:33
@PVince81

Copy link
Copy Markdown
Contributor

@IljaN please adjust tests for code coverage. The new conditions aren't called by tests.

If needed you can check the unit tests for the Util/Scanner

@PVince81

PVince81 commented Jun 5, 2018

Copy link
Copy Markdown
Contributor

I've added tests for the test coverage.

Note that for the stat() call I had to add an @ sign to prevent a PHP warning to be logged.

@PVince81

Copy link
Copy Markdown
Contributor

now it's only codecov again. I can't open the report though...

@IljaN
IljaN force-pushed the verfiy_checksum_fixes branch from 400c690 to 5ba0055 Compare July 16, 2018 14:20
@IljaN

IljaN commented Jul 16, 2018

Copy link
Copy Markdown
Contributor Author

🤞 🤞

@IljaN
IljaN force-pushed the verfiy_checksum_fixes branch from 5ba0055 to c4c6435 Compare July 16, 2018 14:54
@PVince81

Copy link
Copy Markdown
Contributor
1) OCA\Files\Tests\Command\VerifyChecksumsTest::testFileWithoutChecksumIsIgnored
Failed asserting that 'This operation might take quite some time.
Checking 1-verifycheksumsgEEvlSgfKbg6i/files/dir/nested/somefile.txt => SHA1:2ef7bde608ce5404e97d5f042f95f89f1c232871 MD5:ed076287532e86365e841e92bfc50d8c ADLER32:1c49043e
Checking 1-verifycheksumsgEEvlSgfKbg6i/files/dir/nested/somefile2.txt => SHA1:77ba9cd915c8e359d9733edcfe9c61e5aca92afb MD5:e48e13207341b6bffb7fb1622282247b ADLER32:01fe00cf
Checking 1-verifycheksumsgEEvlSgfKbg6i/files/dir/nested/subdir/hallo2.txt => SHA1:f8df862af4cbfed3e19b561186005d353261d2c3 MD5:1e2cb228ed73c2122f0f3a08c1976425 ADLER32:1c1004a4
Checking 1-verifycheksumsgEEvlSgfKbg6i/files/otherdir/bar.txt => SHA1:749de5cc8ef9ff0fb0869179ea66555c2dff2fbf MD5:4c843bd5e890558b89583052fe61a44c ADLER32:03620142
Checking 1-verifycheksumsgEEvlSgfKbg6i/files/rootfile.doc => SHA1:d58f12c8b4ccdf68b6bd115ad8ce8af7d6f48c46 MD5:cbff38f3fa5224405e56bb3feae869d0 ADLER32:2bf605e7
Checking 1-verifycheksumsgEEvlSgfKbg6i/files/song.mp3 => SHA1:7bb865d84faf4da193fd2736ec7a3738bccff7d9 MD5:52a8552679a800dcaf01f2df4702089b ADLER32:576b0859
Checking 2-verifycheksumsiZetO2ZpuAwlA/files/bling.tif => SHA1:308c265b9b9b0d9124cf090181f9157135dc0841 MD5:77f200afb4245c9d13d1c502a844730e ADLER32:1a9803fa
Checking 2-verifycheksumsiZetO2ZpuAwlA/files/pong.tif => SHA1:7b52009b64fd0a2a49e6d8a939753077792b0554 MD5:c20ad4d76fe97759aa27a0c99bff6710 ADLER32:00960064
Checking 2-verifycheksumsiZetO2ZpuAwlA/files/sdvsdvs/secrets/bar/baz/moo.txt => SHA1:f05ea879e5531704ed3f85fab6be849531fe60df MD5:384ecbcf3e7e60e4f7e83a6507221580 ADLER32:19a9044b
Checking 2-verifycheksumsiZetO2ZpuAwlA/files/welcome.doc => SHA1:d58f12c8b4ccdf68b6bd115ad8ce8af7d6f48c46 MD5:cbff38f3fa5224405e56bb3feae869d0 ADLER32:2bf605e7
' contains "somefile.txt => No Checksum".

/drone/src/apps/files/tests/Command/VerifyChecksumsTest.php:316

not sure if this is up to date though

@PVince81

PVince81 commented Aug 3, 2018

Copy link
Copy Markdown
Contributor

@ownclouders rebase

@ownclouders

Copy link
Copy Markdown
Contributor

Hey! I'm GitMate.io! This pull request is being rebased automatically. Please DO NOT push while rebase is in progress or your changes would be lost permanently ⚠️

@ownclouders
ownclouders force-pushed the verfiy_checksum_fixes branch from 2db1762 to f6027a5 Compare August 3, 2018 15:27
@ownclouders

Copy link
Copy Markdown
Contributor

Automated rebase with GitMate.io was successful! 🎉

@PVince81

PVince81 commented Aug 6, 2018

Copy link
Copy Markdown
Contributor

Oracle failure:

There was 1 failure:

1) OCA\Files\Tests\Command\VerifyChecksumsTest::testFileWithoutChecksumIsIgnored
Failed asserting that 'This operation might take quite some time.
Checking 1-verifycheksumsy8HROuV53cdZi/files/dir/nested/somefile.txt => SHA1:2ef7bde608ce5404e97d5f042f95f89f1c232871 MD5:ed076287532e86365e841e92bfc50d8c ADLER32:1c49043e
Checking 1-verifycheksumsy8HROuV53cdZi/files/dir/nested/somefile2.txt => SHA1:77ba9cd915c8e359d9733edcfe9c61e5aca92afb MD5:e48e13207341b6bffb7fb1622282247b ADLER32:01fe00cf
Checking 1-verifycheksumsy8HROuV53cdZi/files/dir/nested/subdir/hallo2.txt => SHA1:f8df862af4cbfed3e19b561186005d353261d2c3 MD5:1e2cb228ed73c2122f0f3a08c1976425 ADLER32:1c1004a4
Checking 1-verifycheksumsy8HROuV53cdZi/files/otherdir/bar.txt => SHA1:749de5cc8ef9ff0fb0869179ea66555c2dff2fbf MD5:4c843bd5e890558b89583052fe61a44c ADLER32:03620142
Checking 1-verifycheksumsy8HROuV53cdZi/files/rootfile.doc => SHA1:d58f12c8b4ccdf68b6bd115ad8ce8af7d6f48c46 MD5:cbff38f3fa5224405e56bb3feae869d0 ADLER32:2bf605e7
Checking 1-verifycheksumsy8HROuV53cdZi/files/song.mp3 => SHA1:7bb865d84faf4da193fd2736ec7a3738bccff7d9 MD5:52a8552679a800dcaf01f2df4702089b ADLER32:576b0859
Checking 2-verifycheksumskcqMUUbwMMHM3/files/bling.tif => SHA1:308c265b9b9b0d9124cf090181f9157135dc0841 MD5:77f200afb4245c9d13d1c502a844730e ADLER32:1a9803fa
Checking 2-verifycheksumskcqMUUbwMMHM3/files/pong.tif => SHA1:7b52009b64fd0a2a49e6d8a939753077792b0554 MD5:c20ad4d76fe97759aa27a0c99bff6710 ADLER32:00960064
Checking 2-verifycheksumskcqMUUbwMMHM3/files/sdvsdvs/secrets/bar/baz/moo.txt => SHA1:f05ea879e5531704ed3f85fab6be849531fe60df MD5:384ecbcf3e7e60e4f7e83a6507221580 ADLER32:19a9044b
Checking 2-verifycheksumskcqMUUbwMMHM3/files/welcome.doc => SHA1:d58f12c8b4ccdf68b6bd115ad8ce8af7d6f48c46 MD5:cbff38f3fa5224405e56bb3feae869d0 ADLER32:2bf605e7
' contains "somefile.txt => No Checksum".

/drone/src/apps/files/tests/Command/VerifyChecksumsTest.php:316

@IljaN

IljaN commented Aug 15, 2018

Copy link
Copy Markdown
Contributor Author

@ownclouders rebase

@ownclouders

Copy link
Copy Markdown
Contributor

Hey! I'm GitMate.io! This pull request is being rebased automatically. Please DO NOT push while rebase is in progress or your changes would be lost permanently ⚠️

@ownclouders
ownclouders force-pushed the verfiy_checksum_fixes branch from f6027a5 to 4a6f584 Compare August 15, 2018 11:39
@ownclouders

Copy link
Copy Markdown
Contributor

Automated rebase with GitMate.io was successful! 🎉

@IljaN

IljaN commented Aug 15, 2018

Copy link
Copy Markdown
Contributor Author

Looks like #32248 fixed this 🎉

@IljaN

IljaN commented Aug 16, 2018

Copy link
Copy Markdown
Contributor Author

Backport #32360

@DeepDiver1975
DeepDiver1975 merged commit 9be90bd into master Aug 16, 2018
@DeepDiver1975
DeepDiver1975 deleted the verfiy_checksum_fixes branch August 16, 2018 10:51
@phil-davis

Copy link
Copy Markdown
Contributor

Backport in #32360 has been merged.

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

7 participants