Utils: Fix copyFile to include permissions

Also adds line breaks to info output.

Change-Id: I314ab87a47d7bd7541acb6a1553238fcfc27099d
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
Marcus Tillmanns
2022-10-25 13:52:04 +02:00
parent b9062e9c80
commit d46a079744
2 changed files with 12 additions and 3 deletions

View File

@@ -1264,7 +1264,16 @@ bool FilePath::copyFile(const FilePath &target) const
const std::optional<QByteArray> ba = fileContents();
if (!ba)
return false;
return target.writeFileContents(*ba);
const auto perms = permissions();
if (!target.writeFileContents(*ba))
return false;
if (!target.setPermissions(perms)) {
target.removeFile();
return false;
}
return true;
}
return fileAccess()->copyFile(*this, target);
}

View File

@@ -1458,7 +1458,7 @@ private:
const FilePath targetDir = target.parentDir();
if (!m_checkedDirectories.contains(targetDir)) {
emit progress(tr("Creating directory: %1")
emit progress(tr("Creating directory: %1\n")
.arg(targetDir.toUserOutput()));
if (!targetDir.ensureWritableDir()) {
result.m_errorString = tr("Failed.");
@@ -1469,7 +1469,7 @@ private:
m_checkedDirectories.insert(targetDir);
}
emit progress(tr("Copying %1/%2: %3 -> %4")
emit progress(tr("Copying %1/%2: %3 -> %4\n")
.arg(m_currentIndex).arg(m_fileCount).arg(source.toUserOutput(), target.toUserOutput()));
if (!source.copyFile(target)) {
result.m_errorString = tr("Failed.");