Skip to content

Commit

Permalink
Merge pull request #559 from ichthyosaurus/fix-520
Browse files Browse the repository at this point in the history
Keep suffices when moving (to) a directory while imitiating pass
  • Loading branch information
annejan committed Mar 21, 2021
2 parents cfac4db + 525cf4a commit f3cb380
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/imitatepass.cpp
Expand Up @@ -350,6 +350,7 @@ void ImitatePass::Move(const QString src, const QString dest,
QFileInfo srcFileInfo(src);
QFileInfo destFileInfo(dest);
QString destFile;
QString srcFileBaseName = srcFileInfo.fileName();

if (srcFileInfo.isFile()) {
if (destFileInfo.isFile()) {
Expand All @@ -360,17 +361,17 @@ void ImitatePass::Move(const QString src, const QString dest,
return;
}
} else if (destFileInfo.isDir()) {
destFile = QDir(dest).filePath(srcFileInfo.baseName());
destFile = QDir(dest).filePath(srcFileBaseName);
} else {
destFile = dest;
}

if (!destFile.endsWith(".gpg"))
destFile.append(".gpg");

if (destFile.endsWith(".gpg", Qt::CaseInsensitive))
destFile.chop(4); // make sure suffix is lowercase
destFile.append(".gpg");
} else if (srcFileInfo.isDir()) {
if (destFileInfo.isDir()) {
destFile = QDir(dest).filePath(srcFileInfo.baseName());
destFile = QDir(dest).filePath(srcFileBaseName);
} else if (destFileInfo.isFile()) {
#ifdef QT_DEBUG
dbg() << "Destination is a file";
Expand All @@ -379,7 +380,6 @@ void ImitatePass::Move(const QString src, const QString dest,
} else {
destFile = dest;
}

} else {
#ifdef QT_DEBUG
dbg() << "Source file does not exist";
Expand Down

0 comments on commit f3cb380

Please sign in to comment.