slotScheduleThisFolder();
}
+void Folder::dehydrateFile(const QString &_relativepath)
+{
+ qCInfo(lcFolder) << "Dehydrating file: " << _relativepath;
+ auto relativepath = _relativepath.toUtf8();
+
+ auto markForDehydration = [&](SyncJournalFileRecord rec) {
+ if (rec._type != ItemTypeFile)
+ return;
+ rec._type = ItemTypeVirtualFileDehydration;
+ _journal.setFileRecord(rec);
+ _localDiscoveryTracker->addTouchedPath(relativepath);
+ };
+
+ SyncJournalFileRecord record;
+ _journal.getFileRecord(relativepath, &record);
+ if (!record.isValid())
+ return;
+ if (record._type == ItemTypeFile) {
+ markForDehydration(record);
+ } else if (record._type == ItemTypeDirectory) {
+ _journal.getFilesBelowPath(relativepath, markForDehydration);
+ } else {
+ qCWarning(lcFolder) << "Invalid existing record " << record._type << " for file " << _relativepath;
+ }
+
+ // Schedule a sync (Folder man will start the sync in a few ms)
+ slotScheduleThisFolder();
+}
void Folder::setUseVirtualFiles(bool enabled)
{
/**
* Mark a virtual file as being ready for download, and start a sync.
- * relativePath is the patch to the file (including the extension)
+ * relativepath is the path to the file (including the extension)
*/
void downloadVirtualFile(const QString &relativepath);
+ /**
+ * Turn a regular file into a dehydrated placeholder.
+ *
+ * relativepath is the path to the file
+ * It's allowed to pass a path to a folder: all contained files will be dehydrated.
+ */
+ void dehydrateFile(const QString &relativepath);
+
private slots:
void slotSyncStarted();
void slotSyncFinished(bool);
{
QStringList files = filesArg.split(QLatin1Char('\x1e')); // Record Separator
- QSet<Folder *> toSync;
for (const auto &file : files) {
auto data = FileData::get(file);
- if (!data.folder)
- continue;
- auto journal = data.folder->journalDb();
- auto markForDehydration = [&](SyncJournalFileRecord rec) {
- if (rec._type != ItemTypeFile)
- return;
- rec._type = ItemTypeVirtualFileDehydration;
- journal->setFileRecord(rec);
- toSync.insert(data.folder);
- };
-
- QFileInfo fi(file);
- if (fi.isDir()) {
- journal->getFilesBelowPath(data.folderRelativePath.toUtf8(), markForDehydration);
- continue;
- }
- auto record = data.journalRecord();
- if (!record.isValid() || record._type != ItemTypeFile)
- continue;
- markForDehydration(record);
+ if (data.folder)
+ data.folder->dehydrateFile(data.folderRelativePath);
}
-
- for (const auto folder : toSync)
- FolderMan::instance()->scheduleFolder(folder);
}
void SocketApi::copyUrlToClipboard(const QString &link)