Skip to content

Commit

Permalink
fix: [io]Modify the default mode for file operations in group policy …
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
liyigang1 authored and deepin-bot[bot] committed Aug 31, 2023
1 parent 74a28d3 commit 85493c1
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 17 deletions.
6 changes: 3 additions & 3 deletions assets/configs/org.deepin.dde.file-manager.operations.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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";
Expand Down

0 comments on commit 85493c1

Please sign in to comment.