-
Notifications
You must be signed in to change notification settings - Fork 669
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
Vfs adjustments for deeper shell integration #7017
Conversation
src/csync/std/c_private.h
Outdated
@@ -42,8 +42,12 @@ | |||
#include <errno.h> | |||
|
|||
#ifdef __MINGW32__ | |||
#ifndef EDQUOT |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where is that even used? perhaps this can simply be removed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like it, will push fixup commits and fold in later
@@ -11,6 +11,7 @@ set(common_SOURCES | |||
${CMAKE_CURRENT_LIST_DIR}/remotepermissions.cpp | |||
${CMAKE_CURRENT_LIST_DIR}/vfs.cpp | |||
${CMAKE_CURRENT_LIST_DIR}/plugin.cpp | |||
${CMAKE_CURRENT_LIST_DIR}/syncfilestatus.cpp |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have you considered moving whatever you need from common to libsync instead?
Since there is no more of csync left, we could move everything together.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason I moved it was because the Vfs
declarations are in common
as they're still used from csync/vio
{ | ||
SyncJournalFileRecord rec; | ||
rec._path = _file.toUtf8(); | ||
rec._path = destination().toUtf8(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could there be a test for that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, would make sense to add db-checks to the SyncMove testsuites. Will do.
SyncJournalFileRecord record = _item->toSyncJournalFileRecordWithInode(propagator()->_localDir + _item->_file); | ||
bool ok = propagator()->_journal->setFileRecord(record); | ||
if (!ok) { | ||
if (!propagator()->updateMetadata(*_item)) { | ||
status = _item->_status = SyncFileItem::FatalError; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some of the error handling could also be moved to the helper
Edit: Maybe not
qCWarning(lcCleanupPolls) << "database error"; | ||
job->_item->_status = SyncFileItem::FatalError; | ||
job->_item->_errorString = tr("Error writing metadata to the database"); | ||
emit aborted(job->_item->_errorString); | ||
deleteLater(); | ||
return; | ||
} | ||
// TODO: Is syncfilestatustracker notified somehow? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is old unused code.
It is going to be updated by #6614
But anyway, no need to update the syncfilestatustracker because this is not about files from this sync, this happen before the discovery.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was wondering whether SyncFileStatusTracker::slotItemCompleted
would ever be emitted for a file that is finished only after polling completes. You're saying that's working fine and the comment can be removed?
@@ -31,7 +31,6 @@ typedef QSharedPointer<Account> AccountPtr; | |||
class SyncJournalDb; | |||
class VfsPrivate; | |||
class SyncFileItem; | |||
typedef QSharedPointer<SyncFileItem> SyncFileItemPtr; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Putting a message on the first line of the commit, but i want to comment on the whole commit)
I do not understand the relation between the commit message and this commit.
It does not seem to touch directory, it is just some refactoring, is it not?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The significant change that happens in "Vfs: Make files that end up in db placeholders" is that convertToPlaceholder()
is called for each updateMetadata()
. Previously it was called much more sparingly and that would cause trouble down the line.
@@ -972,8 +965,15 @@ void PropagateDownloadFile::downloadFinished() | |||
// Apply the remote permissions | |||
FileSystem::setFileReadOnlyWeak(_tmpFile.fileName(), !_item->_remotePerm.isNull() && !_item->_remotePerm.hasPermission(RemotePermissions::CanWrite)); | |||
|
|||
// Make the file a hydrated placeholder if possible | |||
propagator()->syncOptions()._vfs->convertToPlaceholder(_tmpFile.fileName(), *_item, fn); | |||
bool isConflict = _item->_instruction == CSYNC_INSTRUCTION_CONFLICT |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could there be a test for this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added one!
It'll be needed in vfs plugins so they can connect to the data coming out of SyncFileStatusTracker.
Similar steps were done in many propagation jobs. This also updates the db entry to always have the item.destination() as file path.
Since 'placeholder' just means that it's an item of the special type that the vfs plugin can deal with - no matter whether hydrated or dehydrated - all done items should become placeholders. Even directories. Now every file that passes through updateMetadata() will be converted to a placeholder if necessary.
This allows SyncFileStatusTracker to also know about these. After all its information is used to provide icons for them too.
This will be used in conjunction with vfs plugins that detect whether a file has a pending hydration/dehydration through independent means and communicate that to the discovery through local file type.
Possibly the behavior should actually change and the function should de-placeholder all items, not just dehydrated ones.
Needs to be disabled for tests in some cases.
- unspecified and inherited are different - move enum to header in common/ - access through Vfs instead of directly in Journal
Any folder with a (potentially deeply) contained error will have StatusWarning. StatusExcluded marks exclusions. The difference is useful to know for VFS.
There were cases where the "/" exception wasn't handled correctly and there'd be extra slashes in generated paths.
- SyncJournalDB functions now behind internalPinStates() to avoid accidental usage, when nearly everyone should go through Vfs. - Rename Vfs::getPinState() to Vfs::pinState()
Previously they would be discarded since the file's mtime or size hadn't changed.
Allows for better attribute preservation. Also add verifyFileUnchanged() call before dehydration to avoid data loss when discovery takes a while.
The block of code that propagated attributes etc from the previously existing file was placed *after* the block that renamed the previously existing file to a conflict name. That meant the propagation didn't work in the conflict case.
Because some plugins provide alternative ui.
That just complicated things. It's ok if Vfs is not a fully abstract interface class. The pinstate-in-db methods are instead provided directly on Vfs and VfsSuffix and VfsOff use them to implement pin states. The start() method is simply non-virtual and calls into startImpl() for the plugin-specific startup code.
In tests an un-started Vfs instance is sometimes passed to SyncEngine via SyncOptions.
Fixes a bug introduced while moving the attribute propagation before the conflict-renaming.
That change will be useful for the notifications. Previously the dehydrated files were reported as "newly downloaded", now they're reported as "updated".
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.
For moves it's relevant that the old db entry is removed and the new one is created at the right location.
Also covering propagation to the downloaded file when a conflict-rename is done at the same time, which used to not work.
8b43d18
to
fd8dd79
Compare
This is