Repository navigation
Conversation
There was a problem hiding this comment.
` missing on PREFIXmimetypes
|
I've added the missing backticks. |
|
Good point. I'll make it default to -1 (the original result) if an exception occurs, and log the exception. |
|
Ok done, see last commit. |
|
Can we get test coverage for this? |
|
SQLite does not support subqueries to my knowledge. Consider using joins. |
|
Good point, I was just considering testing it with SQLite. |
|
Could probably also just extract the queries. |
|
Note to self: also check that this works correctly when "/Shared" is present. The calculation might currently differ from the real value because it seems that shared files are currently counted in the "used space" while scanning (inferred from #5688) |
|
It looks like OC 6 doesn't count the contents of "/Shared" in the actual quota, which means the calculation done in this PR is indeed correct. |
|
But it does seem that the root dir takes into account the size of files that have been uploaded into other user's shared dir. This needs to be cleared out in #2796 first. |
|
I'm not sure whether this PR is the best fix. I had the issue again on my private ownCloud and tried applying this PR as patch. The sync client works again, but in the DB I see that the "-1" of the root never gets updated.
As you can see, only the "files" dir has a size set. The root is the sum of all, but if a -1 is found, it stays -1. The fix in this PR just bypasses this wrong value and sums up all files every time, which might have a performance impact if it stays that way. 😦 |
|
I think I'll have a try changing that SELECT to an UPDATE to prevent future calls to need to do the sum many times. The "real" size should overwrite that value whenever Cache::correctFolderSize() is called at some point by a watcher. |
In some cases when a scan process is in progress (or not started yet), the root folder might have subfolder with the size of -1. Since the quota is calculated based on the root folder size, it is not good to let that size be overwritten. In such case, the size will be calculated by ignoring the non-scanned subfolders. At some point, the scan process in these subfolders will update the root size again eventually. Fixes #5509
|
I decided to go with another approach, and rebased/removed all commits into that one. Before the fix, we sometimes get a situation like this (sometimes even while syncing)): At this point, if you upload a file into /files, the method Cache::calculateFolderSize() is called on all parents up to the root. When calculating the root size, it would see the "-1" and decide that the root size is unknown and write a "-1" there, which breaks the quota. This fix fixes the logic for the root folder and makes it ignore "-1" subdirs to prevent such situation. Normally, the "-1" subdirs should only be there initially, maybe at the time where some app has inited its subdir. Once the scan has run, the real size will appear there and add itself to the root total. Please review @bantu @icewind1991 @DeepDiver1975 @karlitschek |
|
Ok ok Oracle, I get it. I'll add the backticks... |
|
Test passed. |
|
Please review @DeepDiver1975 @karlitschek @bantu @icewind1991 @schiesbn |
|
👍 |
|
👎 this will effect the root for every storage, including external ones |
|
see #5768 instead |
|
Good catch. |
|
@icewind1991 just thought maybe it isn't that bad to have this "don't overwrite root size with -1" for other storages as well. In the future we might want to know how much space is used there as well (or have storage based quotas which would also need this fix). Or would this PR break something related to ext storage that I am not aware of ? |
|
@icewind1991 @PVince81 So this can be closed? |
|
Yes, closing. |
In some cases when a scan process is in progress (or not started yet),
the root folder might have a size of -1.
To make sure that the quota can still be calculated correctly, an
special SQL query is used to pre-calculate the root folder size by
summing the size of all known files, which is better than no value at
all.
Fixes #5509
Please review @DeepDiver1975 @icewind1991 @karlitschek
This shouldn't happen too often, only when some race condition occurs.
If it is not acceptable to select that way (in case it still happens too often), we can replace it with an UPDATE that writes the value into the DB, which might have some other side effects related to scanners (but unlikely)