From 85493c16ac312ccdc14059364255478fed689897 Mon Sep 17 00:00:00 2001 From: liyigang Date: Thu, 31 Aug 2023 09:04:07 +0800 Subject: [PATCH] fix: [io]Modify the default mode for file operations in group policy to be high performance mode. Modify the default mode for file operations in group policy to be high performance mode. Log: Modify the default mode for file operations in group policy to be high performance mode. Bug: https://pms.uniontech.com/bug-view-215793.html --- ...org.deepin.dde.file-manager.operations.json | 6 +++--- .../fileoperationutils/docopyfileworker.cpp | 6 ++++++ .../fileoperatebaseworker.cpp | 18 ++++-------------- 3 files changed, 13 insertions(+), 17 deletions(-) diff --git a/assets/configs/org.deepin.dde.file-manager.operations.json b/assets/configs/org.deepin.dde.file-manager.operations.json index ba0fb69cb5..92feba3865 100644 --- a/assets/configs/org.deepin.dde.file-manager.operations.json +++ b/assets/configs/org.deepin.dde.file-manager.operations.json @@ -14,13 +14,13 @@ "visibility":"private" }, "file.operation.blockeverysync": { - "value":true, + "value":false, "serial":0, "flags":[], "name":"Safe synchronization mode", "name[zh_CN]":"安全同步模式", - "description[zh_CN]":"安全同步模式是拷贝到外设块设备时,每次写入执行同步到设备。高性能模式是拷贝到外设块设备时,每个任务完成后在进行同步到设备。默认是安全同步模式。", - "description":"Safe synchronization mode is when copying to a peripheral block device, synchronize to the device for each write. High-performance mode is to synchronize to the device after each task is completed when copying to a peripheral block device.The default is safe synchronization mode.", + "description[zh_CN]":"安全同步模式是拷贝到外设块设备时,每次写入执行同步到设备。高性能模式是拷贝到外设块设备时,每个任务完成后在进行同步到设备。默认是高性能模式(即关闭安全同步模式)。", + "description":"Safe synchronization mode is when copying to a peripheral block device, synchronize to the device for each write. High-performance mode is to synchronize to the device after each task is completed when copying to a peripheral block device.Default is high performance mode (i.e. turn off safe synchronization mode).", "permissions":"readwrite", "visibility":"private" } diff --git a/src/plugins/common/core/dfmplugin-fileoperations/fileoperations/fileoperationutils/docopyfileworker.cpp b/src/plugins/common/core/dfmplugin-fileoperations/fileoperations/fileoperationutils/docopyfileworker.cpp index 17b1f95af5..7f66a3c23e 100644 --- a/src/plugins/common/core/dfmplugin-fileoperations/fileoperations/fileoperationutils/docopyfileworker.cpp +++ b/src/plugins/common/core/dfmplugin-fileoperations/fileoperations/fileoperationutils/docopyfileworker.cpp @@ -222,6 +222,8 @@ bool DoCopyFileWorker::doCopyFilePractically(const FileInfoPointer fromInfo, con setTargetPermissions(fromInfo, toInfo); workData->zeroOrlinkOrDirWriteSize += FileUtils::getMemoryPageSize(); FileUtils::notifyFileChangeManual(DFMBASE_NAMESPACE::Global::FileNotifyType::kFileAdded, toInfo->urlOf(UrlInfoType::kUrl)); + if (workData->exBlockSyncEveryWrite) + sync(); return true; } // resize target file @@ -264,6 +266,10 @@ bool DoCopyFileWorker::doCopyFilePractically(const FileInfoPointer fromInfo, con delete[] data; data = nullptr; + // 执行同步策略 + if (workData->exBlockSyncEveryWrite && toFd > 0) + syncfs(toFd); + if (toFd > 0) close(toFd); diff --git a/src/plugins/common/core/dfmplugin-fileoperations/fileoperations/fileoperationutils/fileoperatebaseworker.cpp b/src/plugins/common/core/dfmplugin-fileoperations/fileoperations/fileoperationutils/fileoperatebaseworker.cpp index 1328524ce2..ef32ab6a99 100644 --- a/src/plugins/common/core/dfmplugin-fileoperations/fileoperations/fileoperationutils/fileoperatebaseworker.cpp +++ b/src/plugins/common/core/dfmplugin-fileoperations/fileoperations/fileoperationutils/fileoperatebaseworker.cpp @@ -1305,12 +1305,10 @@ void FileOperateBaseWorker::determineCountProcessType() if (targetIsRemovable) { workData->exBlockSyncEveryWrite = FileOperationsUtils::blockSync(); - countWriteType = workData->exBlockSyncEveryWrite ? - CountWriteSizeType::kCustomizeType : - CountWriteSizeType::kWriteBlockType; + countWriteType = workData->exBlockSyncEveryWrite ? CountWriteSizeType::kCustomizeType : CountWriteSizeType::kWriteBlockType; + targetDeviceStartSectorsWritten = workData->exBlockSyncEveryWrite ? 0 : getSectorsWritten(); + workData->isBlockDevice = true; - targetDeviceStartSectorsWritten = workData->exBlockSyncEveryWrite ? - 0 : getSectorsWritten(); } qDebug("Block device path: \"%s\", Sys dev path: \"%s\", Is removable: %d, Log-Sec: %d", @@ -1333,15 +1331,7 @@ void FileOperateBaseWorker::syncFilesToDevice() return; qInfo() << "start sync all file to extend block device!!!!! target : " << targetUrl; - for (const auto &url : completeTargetFiles) { - std::string stdStr = url.path().toUtf8().toStdString(); - int tofd = open(stdStr.data(), O_RDONLY); - if (-1 != tofd) { - syncfs(tofd); - close(tofd); - } - } - + sync(); qInfo() << "end sync all file to extend block device!!!!! target : " << targetUrl; qDebug() << __FUNCTION__ << "syncFilesToDevice begin";