Discovery: Files can have dehydrate/download actions

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.
This commit is contained in:
Christian Kamm 2019-01-22 13:32:28 +01:00 committed by Kevin Ottens
parent af1666788e
commit 5820ac8b41
No known key found for this signature in database
GPG key ID: 074BBBCB8DECC9E2
3 changed files with 25 additions and 5 deletions

View file

@ -136,8 +136,23 @@ enum ItemType {
ItemTypeSoftLink = 1,
ItemTypeDirectory = 2,
ItemTypeSkip = 3,
/** The file is a dehydrated placeholder, meaning data isn't available locally */
ItemTypeVirtualFile = 4,
/** A ItemTypeVirtualFile that wants to be hydrated.
*
* Actions may put this in the db as a request to a future sync.
* For some vfs plugins the placeholder files on disk may be marked for
* dehydration (like with a file attribute) and then the local discovery
* will return this item type.
*/
ItemTypeVirtualFileDownload = 5,
/** A ItemTypeFile that wants to be dehydrated.
*
* May exist in db or local files, similar to ItemTypeVirtualFileDownload.
*/
ItemTypeVirtualFileDehydration = 6,
};

View file

@ -281,7 +281,8 @@ void ProcessDirectoryJob::processFile(PathTuple path,
<< " | checksum: " << dbEntry._checksumHeader << "//" << serverEntry.checksumHeader
<< " | perm: " << dbEntry._remotePerm << "//" << serverEntry.remotePerm
<< " | fileid: " << dbEntry._fileId << "//" << serverEntry.fileId
<< " | inode: " << dbEntry._inode << "/" << localEntry.inode << "/";
<< " | inode: " << dbEntry._inode << "/" << localEntry.inode << "/"
<< " | type: " << dbEntry._type << "/" << localEntry.type << "/" << (serverEntry.isDirectory ? ItemTypeDirectory : ItemTypeFile);
if (_discoveryData->isRenamed(path._original)) {
qCDebug(lcDisco) << "Ignoring renamed";
@ -325,7 +326,9 @@ void ProcessDirectoryJob::processFile(PathTuple path,
// server-side nothing has changed
// NOTE: Normally setting the VirtualFileDownload flag means that local and
// remote will be rediscovered. This is just a fallback.
if (_queryServer == ParentNotChanged && dbEntry._type == ItemTypeVirtualFileDownload) {
if (_queryServer == ParentNotChanged
&& (dbEntry._type == ItemTypeVirtualFileDownload
|| localEntry.type == ItemTypeVirtualFileDownload)) {
item->_direction = SyncFileItem::Down;
item->_instruction = CSYNC_INSTRUCTION_NEW;
item->_type = ItemTypeVirtualFileDownload;
@ -371,7 +374,7 @@ void ProcessDirectoryJob::processFileAnalyzeRemoteInfo(
item->_direction = SyncFileItem::Down;
item->_modtime = serverEntry.modtime;
item->_size = serverEntry.size;
} else if (dbEntry._type == ItemTypeVirtualFileDownload) {
} else if (dbEntry._type == ItemTypeVirtualFileDownload || localEntry.type == ItemTypeVirtualFileDownload) {
item->_direction = SyncFileItem::Down;
item->_instruction = CSYNC_INSTRUCTION_NEW;
item->_type = ItemTypeVirtualFileDownload;
@ -706,7 +709,7 @@ void ProcessDirectoryJob::processFileAnalyzeLocalInfo(
if (noServerEntry) {
item->_instruction = CSYNC_INSTRUCTION_REMOVE;
item->_direction = SyncFileItem::Down;
} else if (dbEntry._type == ItemTypeVirtualFileDehydration) {
} else if (dbEntry._type == ItemTypeVirtualFileDehydration || localEntry.type == ItemTypeVirtualFileDehydration) {
item->_direction = SyncFileItem::Down;
item->_instruction = CSYNC_INSTRUCTION_NEW;
item->_type = ItemTypeVirtualFileDehydration;
@ -1340,7 +1343,8 @@ bool ProcessDirectoryJob::runLocalQuery()
i.isDirectory = dirent->type == ItemTypeDirectory;
i.isHidden = dirent->is_hidden;
i.isSymLink = dirent->type == ItemTypeSoftLink;
i.isVirtualFile = dirent->type == ItemTypeVirtualFile;
i.isVirtualFile = dirent->type == ItemTypeVirtualFile || dirent->type == ItemTypeVirtualFileDownload;
i.type = dirent->type;
_localNormalQueryEntries.push_back(i);
}
csync_vio_local_closedir(dh);

View file

@ -68,6 +68,7 @@ struct LocalInfo
time_t modtime = 0;
int64_t size = 0;
uint64_t inode = 0;
ItemType type = ItemTypeSkip;
bool isDirectory = false;
bool isHidden = false;
bool isVirtualFile = false;