Commit graph

567 commits

Author SHA1 Message Date
Christian Kamm
b974f579ae
Chunked upload: Fix percent encoding in If header #7176 2020-12-15 10:58:50 +01:00
Christian Kamm
9f3578b276
Tests: Fix DB locking issue in permissions test 2020-12-15 10:58:50 +01:00
Christian Kamm
a0457d5e1d
Tests: fix vfs availability test case 2020-12-15 10:58:50 +01:00
Christian Kamm
7f3f13fd97
Vfs: "free space" only shows when it has an effect #7143
To do this, introduce AllDehydrated availability and rename
SomeDehydrated to Mixed - it now guarantees there are also hydrated
items.
2020-12-15 10:58:49 +01:00
Christian Kamm
021f994584
FolderWizard: Don't crash when typing invalid drive #7041
When the user typed "x:" where the drive x didn't exist, the validation
function would loop forever. Now it shows a "path doesn't exist" error.
2020-12-15 10:58:49 +01:00
Christian Kamm
fbe2dbf4ab
Discovery: Query data-fingerprint on root item
Previously the property wasn't queried, meaning the fingerprint logic
couldn't get triggered.
2020-12-15 10:58:48 +01:00
Christian Kamm
c50f041c5b
Discovery: 403 and 503 on root cause error
Previously these result codes during remote discovery of the sync root
would not cause an error and the discovery would get stuck.

Also extends RemoteDiscovery tests to check for errors on the root item.
2020-12-15 10:58:48 +01:00
Christian Kamm
dcf34316fd
Vfs: Add 'availability', a simplified, user-facing pin state #7111
The idea is that the user's question is "is this folder's data available
offline?" and not "does this folder have AlwaysLocal pin state?".
The the answers to the two questions can differ: an always-local
folder can have subitems that are not always-local and are dehydrated.

The new availability enum intends to describe the answer to the user's
actual question and can be derived from pin states. If pin states aren't
stored in the database the way of calculating availability will depend
on the vfs plugin.
2020-12-15 10:58:47 +01:00
Christian Kamm
590db28541
Vfs: Clear up relationship between _type and pin state
The pin state is a per-item attribute that has an effect on _type:
AlwaysLocal dehydrated files will be marked for hydration and OnlineOnly
hydrated files will be marked for dehydration.

Where exactly this effect materializes depends on how the pin states are
stored. If they're stored in the db (suffix) the dbEntry._type is
changed during the discovery.

If the pin state is stored in the filesystem, the localEntry._type must
be adjusted by the plugin's stat callback.

This patch makes pin states behave more consistently between plugins.
Previously with suffix-vfs pin states only had an effect on new remote
files. Now the effect of pinning or unpinning files or directories is as
documented and similar to other plugins.
2020-12-15 10:58:46 +01:00
Christian Kamm
cd10e3d28c
PropagateDirectory: Set initial dir mtime to server mtime #7119
It's still not synced in any way later.
2020-12-15 10:58:46 +01:00
Christian Kamm
fd9b01981b
Detect missing server data during discovery #7112
This has two positive effects:
- We can put the error on the particular file that has missing data
- We can sync all other files
2020-12-15 10:58:46 +01:00
Christian Kamm
4bab93b246
Vfs: Better handling and more tests for suffix file renames
Previously removing the vfs suffix of a file always triggered a
conflict. Now it may just cause a file download.

This was done because users expected symmetry in the rename actions and
renaming foo -> foo.owncloud already triggers the "make the file
virtual" action. Now foo.owncloud -> foo triggers the "download the
contents" action.
2020-12-15 10:58:46 +01:00
Christian Kamm
3f55f9302e
Vfs: Hydrating a virtual is SYNC not NEW #7101
Previously it'd be NEW(ItemTypeFile), but now it has changed to be
SYNC(ItemTypeVirtualFileDownload) which allows better classification.
2020-12-15 10:58:45 +01:00
Christian Kamm
47f10fbf96
Fix and test _file and _renameTarget
There was a bunch of inconsistency around whether _file was set to
_renameTarget or not. This is now never done, passing on more
information.
2020-12-15 10:58:44 +01:00
Olivier Goffart
afbb580528
Test: fix compilation with GCC 4.9
It does not appear to support variadic lambda
2020-12-15 10:58:44 +01:00
Christian Kamm
0cf19123a7
VFS: Unbreak behavior for rename+hydrate #7001
Users can rename a file *and* add/remove the vfs suffix at the same time
leading to very complex sync actions. This patch doesn't add support for
them, but adds tests and makes sure these cases do not cause unintened
behavior.

The rename will be propagated, but the users's hydrate/dehydrate request
will be ignored.
2020-12-15 10:58:44 +01:00
Olivier Goffart
46bf3ed31a
Upload: asynchronious operations
Implements https://github.com/owncloud/core/pull/31851
2020-12-15 10:58:44 +01:00
Christian Kamm
4bd062f5be
OwnSql: Distinguish no-data from error #6677
This could fix a problem where the client incorrectly decides to delete
local data.

Previously any sqlite3_step() return value that wasn't SQLITE_ROW would
be interpreted as "there's no more data here". Thus an sqlite error at a
bad time could cause the remote discovery to fail to read an unchanged
subtree from the database. These files would then be deleted locally.

With this change sqlite errors from sqlite3_step are detected and
logged. For the particular case of SyncJournalDb::getFilesBelowPath()
the error will now be propagated and the sync run will fail instead of
performing spurious deletes.

Note that many other database functions still don't distinguish
not-found from error cases. Most of them won't have as severe effects on
affected sync runs though.
2020-12-15 10:58:43 +01:00
Christian Kamm
575935ded0
Windows: Forbid chars 0-31 in filenames #6987 2020-12-15 10:58:42 +01:00
Christian Kamm
93afc2a04b
Discovery win: Fix detection of case-only renames
Previously they were detected as DELETE+NEW because if "a" is renamed to
"A" then QFile::exists("a") will still return true on Windows.
2020-12-15 10:58:42 +01:00
Christian Kamm
238ac53666
Ensure local discovery on selective sync changes
As far as I'm aware local discovery can be skipped on folders that are
selective-sync blacklisted, so a local discovery is required when an
entry is removed from the blacklist.

Also rename
avoidReadFromDbOnNextSync() -> schedulePathForRemoteDiscovery()
since the old name might also imply it's not read from db in the local
discovery - which is not the case. Use Folder::
schedulePathForLocalDiscovery() for that.
2020-12-15 10:58:41 +01:00
Christian Kamm
4c04351360
Fix warnings about signedness
Sizes are always qint64, not unsigned.
TransferIds are always uint.
2020-12-15 10:58:41 +01:00
Christian Kamm
60cb5d3b34
Tests: Fix permission propagation check
It was using the wrong path to the conflict file.
2020-12-15 10:58:41 +01:00
Christian Kamm
5089f55629
Test: Add check for permission propagation
Also covering propagation to the downloaded file when a conflict-rename
is done at the same time, which used to not work.
2020-12-15 10:58:41 +01:00
Christian Kamm
aed1f28980
Tests: Add db checks to rename/move tests
For moves it's relevant that the old db entry is removed and the new one
is created at the right location.
2020-12-15 10:58:41 +01:00
Christian Kamm
910ccaf600
Vfs: Improve sync protocol entries for actions
Creating a new virtual file and replacing a file with a virtual one now
have their own text in the protocol, not just "Downloaded".

To do this, the SyncFileItem type is kept as
ItemTypeVirtualFileDehydration for these actions. Added new code to
ensure the type isn't written to the database.

While looking at this, I've also added documentation on SyncFileItem's
_file, _renameTarget, _originalFile and destination() because some of
the semantics weren't clear.
2020-12-15 10:58:41 +01:00
Christian Kamm
f24687ec93
Vfs: Make dehydration a SYNC and not a NEW action
That change will be useful for the notifications. Previously the
dehydrated files were reported as "newly downloaded", now they're
reported as "updated".
2020-12-15 10:58:40 +01:00
Christian Kamm
8a8e93827f
Vfs suffix: Fix dehydration creating the wrong db entry 2020-12-15 10:58:40 +01:00
Christian Kamm
83a818678f
PinStates cleanup
- SyncJournalDB functions now behind internalPinStates() to avoid
accidental usage, when nearly everyone should go through Vfs.
- Rename Vfs::getPinState() to Vfs::pinState()
2020-12-15 10:58:39 +01:00
Christian Kamm
0eb4065197
Folder: Add remoteFolderTrailingSlash()
There were cases where the "/" exception wasn't handled correctly
and there'd be extra slashes in generated paths.
2020-12-15 10:58:39 +01:00
Christian Kamm
01f7bc7b49
SyncFileStatusTracker: Distinguish Warning and Excluded
Any folder with a (potentially deeply) contained error will have
StatusWarning. StatusExcluded marks exclusions. The difference is useful
to know for VFS.
2020-12-15 10:58:38 +01:00
Christian Kamm
7f400e3226
Pin state updates
- unspecified and inherited are different
- move enum to header in common/
- access through Vfs instead of directly in Journal
2020-12-15 10:58:38 +01:00
Christian Kamm
4d58208676
File watcher: Reduce touch ignore duration
On Linux and Windows the file watcher can't distinguish between changes
that were caused by the process itself, like during a sync operation,
and external changes. To work around that the client keeps a list of
files it has touched and blocks notifications on these files for a bit.

The duration of this block was originally and arbitrarily set at 15
seconds. During manual tests I regularly thought there was a bug when
syncs didn't trigger, when the only problem was that my changes happened
too close to a previous sync operation.

This change reduces the duration to three seconds. I imagine that this
is still enough.

Also use std::chrono while at it.
2020-12-15 10:58:36 +01:00
Olivier Goffart
6f4bf585f0
Move: Fix move detection in directory move on the other side 2020-12-15 10:58:35 +01:00
Olivier Goffart
88d02a887f
Move: add comments and tests 2020-12-15 10:58:35 +01:00
Olivier Goffart
1fb4c22adf
Move: add more test and fix move within moves 2020-12-15 10:58:35 +01:00
Olivier Goffart
ade4c11de3
Rename: fix renamed folder moved into renamed folder issue
Issue #6694
2020-12-15 10:58:35 +01:00
Christian Kamm
836d298141
vfs suffix: Ignore server files or synced files with the suffix #6953 2020-12-15 10:58:34 +01:00
Christian Kamm
20ef0a0290
vfs: Allow retrieving of pin state paths and flags 2020-12-15 10:58:33 +01:00
Christian Kamm
4df101ed84
vfs: Allow (de-)hydrating the full sync folder 2020-12-15 10:58:33 +01:00
Christian Kamm
aa382eda29
Db: Add wiping of pin state for subtrees 2020-12-15 10:58:30 +01:00
Christian Kamm
d956f518a8
vfs: Remove newFilesAreVirtual - use root PinState instead
This unifies how to deal with pin states.

Also enable reading a folders direct pin state vs its effective pin
state.
2020-12-15 10:58:30 +01:00
Olivier Goffart
62ec4c9330
Discovery: Handle the blacklistFiles from the server capabilities
Issue #434

Ideally one could add the blacklist to the exlucde reggexp, but this
is simpler
2020-12-15 10:58:30 +01:00
Christian Kamm
486c25cb47
vfs: Use PinState in sync algorithm #6815
New files are virtual if the file's pin state is OnlineOnly.
2020-12-15 10:58:29 +01:00
Christian Kamm
68126ac208
vfs: Introduce PinState db storage #6815
The idea is to allow folders (and later maybe files?) to be
- pinned to be available locally
- pinned to be online only
- inherit their pin from the parent

Where this pinning only controls the default for new files.
Subfolders may have a different pin state, and contained files
may be hydrated or dehydrated based on user actions.

This value is stored in a new 'flags' table. The idea is to store
data there that doesn't necessarily exist for each metadata entry.
The selective sync state could be migrated to this table.
2020-12-15 10:58:29 +01:00
Olivier Goffart
dfedb09fd8
Move test for issue #1329 from t1.pl to new test system 2020-12-15 10:58:29 +01:00
Olivier Goffart
a29320b18d
Discovery: Set right direction when restoring deleted discovery because it has modified files
(Catched by a faillure of t1.pl)
2020-12-15 10:58:29 +01:00
Olivier Goffart
6da96cd026
Port the exclude test to the QTest Framework
This is just a port to QtTest, I did not change the layout of the test.
I did search and replace to replace the assert with QCOMPARE/QVERIFY
I still call setup and setup_init like before (only explicitly, now)

Also ported the preformence tests to QBENCHMAK because windows don't have
gettimeofday.

Relates #6358
2020-12-15 10:58:29 +01:00
Olivier Goffart
fad1238b33
Test: Move the test for Utility::normalizeEtag to testutility.cpp
I just moved the text and did the minimum to port it to QtTest
Did not change hte layout of it.

Relates #6358
2020-12-15 10:58:28 +01:00
Olivier Goffart
6e048a2d3f
Remove check_csync_util
It's testing nothing.
Only that one can convert a csync instruction to a string.
But this is only used in debug anyway

Relates to #6358
2020-12-15 10:58:28 +01:00