Skip to content
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

TextEditor: Checksum not invalidated on file change #23782

Closed
dragotin opened this issue Apr 4, 2016 · 16 comments · Fixed by #24098
Closed

TextEditor: Checksum not invalidated on file change #23782

dragotin opened this issue Apr 4, 2016 · 16 comments · Fixed by #24098

Comments

@dragotin
Copy link
Contributor

dragotin commented Apr 4, 2016

Steps to reproduce

  1. Create a text file with the sync client
  2. Wait until it is synced.
  3. Check that it has a checksum in the database, which was sent from the client.
  4. Edit the file from the built in texteditor, let it save.
  5. See that the checksum of the file has not changed.

Expected behaviour

When a file is changed, the checksum on the server needs to be recalculated. If that can not be done, it needs at least to be invalidated.

Having a wrong checksum for a file is a critical problem as the client will complain about a corrupted file.

Server configuration

Operating system:
Linux
Web server:
apache
Database:
mysql
PHP version:
5.5.14
ownCloud version: (see ownCloud admin page)
9.0.x, master branch, 15833d9
Updated from an older ownCloud or fresh install:

Where did you install ownCloud from:
git
Are you using external storage, if yes which one: local/smb/sftp/...
no external storage
Are you using encryption: yes/no
no encryption
Are you using an external user-backend, if yes which one: LDAP/ActiveDirectory/Webdav/...
no user-backend.

@MorrisJobke
Copy link
Contributor

sev3 because there is not yet any client out there that uses the checksums.

@MorrisJobke MorrisJobke added this to the 9.1-current milestone Apr 4, 2016
@rullzer
Copy link
Contributor

rullzer commented Apr 4, 2016

mmmm I don't get this. Doesn't the texteditor use dav?

@rullzer
Copy link
Contributor

rullzer commented Apr 4, 2016

Ah no it seems it uses internal calls. So when we modify a file we must just reset the checksum to the empty string. @icewind1991 can you help with that?

I think it only has to be handled in the view.php::file_put_contents function right?

@rullzer rullzer modified the milestones: 9.0.2-next-maintenance, 9.1-current Apr 4, 2016
@rullzer
Copy link
Contributor

rullzer commented Apr 4, 2016

Raised to sev2 as this has to be fixed for 9.0.2 from my POV. @cmonteroluque

@dragotin
Copy link
Contributor Author

dragotin commented Apr 4, 2016

@MorrisJobke ...exept the few desktop clients (version 2.1.1) that some enthusiasts might use ;-). The client uses the checksum to validate the download from the server by comparing the server stored checksum to one that the client calculates after download.

With this bug, the client will refuse the download of the file once it was saved by the text editor because the checksums do not match. I wonder which other apps use "internal calls" to store data and have the same problem.

Well, morris, the fix is easy once the users call because of this: Just update the filecache and set all checksums to empty. 😢

@MorrisJobke
Copy link
Contributor

exept the few desktop clients (version 2.1.1) that some enthusiasts might use ;-)

Oh. Really? I thought it will be present in the next major release 🙈 Sorry

@MorrisJobke
Copy link
Contributor

Raised to sev2 as this has to be fixed for 9.0.2 from my POV. @cmonteroluque

Yep.

@ghost
Copy link

ghost commented Apr 5, 2016

I agree

@rullzer
Copy link
Contributor

rullzer commented Apr 19, 2016

Ok let me dive into this.

@rullzer rullzer self-assigned this Apr 19, 2016
@rullzer
Copy link
Contributor

rullzer commented Apr 19, 2016

Ok there are actually a few scenarios here.

There is the scenario where somebody calls file_put_content. I have that fixed locally I think. We then just clear the checksum.

But what to do if somebody calls fopen. I think it is safest just to also clear the checksum if the file is opened with write. We may look into the future into a wrapper or something that only clears is actually something is writen/deleted. But for now clearing seems best. CC: @PVince81 @dragotin

rullzer added a commit that referenced this issue Apr 19, 2016
Part 1 of #23782

If we overwrite a file we should clear the stored checksum as it is no
longer valid.

* Unit test added
@rullzer
Copy link
Contributor

rullzer commented Apr 19, 2016

PR 1 of 2 in #24098

@PVince81
Copy link
Contributor

@rullzer yes, I guess you meant only for fopen in one of the write modes, not read.
You might also be able to do it at close time, see https://github.com/owncloud/core/blob/v9.0.1/lib/private/files/view.php#L1092 (this code is run after the file was closed).

It's probably best to clear the checksum in one of the existing database calls instead of adding new ones though (which makes the "close time" approach less interesting)

@rullzer
Copy link
Contributor

rullzer commented Apr 19, 2016

Yes I agree. But the current calls don't allow me to easily inject it there.. without doing it all the time. For example on move and copy we don't want to clear the checksum etc.

rullzer added a commit that referenced this issue Apr 19, 2016
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
Copy link
Contributor

rullzer commented Apr 19, 2016

PR that fixes both cases in #24098 now

rullzer added a commit that referenced this issue Apr 20, 2016
Fixes #23782 and #23783

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

* Unit test added
@MorrisJobke MorrisJobke modified the milestones: 9.1-current, 9.0.2-current-maintenance Apr 20, 2016
@rullzer
Copy link
Contributor

rullzer commented Apr 20, 2016

Stable 9 backport in #24129

@lock
Copy link

lock bot commented Aug 4, 2019

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 4, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants