summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
1f692ef)
Signed-off-by: Lukas Hrazky <lukkash@email.cz>
-#define ERROR_PROMPT_XP(operation, promptString, fileName, onIgnore, quitCmd) \
+#define SPECIAL_COPY_ERROR_PROMPT(operation, promptString, fileName) \
{ \
ERROR_PROMPT(operation, promptString, fileName) \
if (abort || response == FileOperator::IGNORE) { \
{ \
ERROR_PROMPT(operation, promptString, fileName) \
if (abort || response == FileOperator::IGNORE) { \
- if (!abort) onIgnore; \
- quitCmd; \
+ if (!abort) { \
+ updateProgress(fileSizeMap[path]); \
+ removeExcludeFiles.insert(path); \
+ } \
+ return; \
std::cout << "DELETING " << file.absoluteFilePath().toStdString() << std::endl;
QString path = file.absoluteFilePath();
std::cout << "DELETING " << file.absoluteFilePath().toStdString() << std::endl;
QString path = file.absoluteFilePath();
+
+ if (removeExcludeFiles.contains(path)) {
+ if (doUpdates) updateProgress(1);
+ return false;
+ }
+
QFSFileEngine engine(path);
if (doUpdates) updateFile(path);
if (file.isDir()) {
QFSFileEngine engine(path);
if (doUpdates) updateFile(path);
if (file.isDir()) {
- if (!remove(listDirFiles(path), doUpdates)) return false;
+ if (!remove(listDirFiles(path), doUpdates)) {
+ if (doUpdates) updateProgress(1);
+ return false;
+ }
if (!listDirFiles(path).size()) {
ERROR_PROMPT(!engine.rmdir(path, false), tr("Error deleting directory %1."), path)
if (!listDirFiles(path).size()) {
ERROR_PROMPT(!engine.rmdir(path, false), tr("Error deleting directory %1."), path)
if (response == FileOperator::KEEP) {
updateProgress(fileSizeMap[path]);
if (response == FileOperator::KEEP) {
updateProgress(fileSizeMap[path]);
+ removeExcludeFiles.insert(path);
}
if (!newFile.exists()) {
}
if (!newFile.exists()) {
- ERROR_PROMPT_XP(!engine.mkdir(newPath, false),
- tr("Error creating directory %1."), newPath,
- updateProgress(fileSizeMap[path]),
- return)
+ SPECIAL_COPY_ERROR_PROMPT(!engine.mkdir(newPath, false),
+ tr("Error creating directory %1."), newPath)
dest = destBackup;
} else {
dest = destBackup;
} else {
- ERROR_PROMPT_XP(engine.isSequential(),
- tr("Cannot copy sequential file %1."), path,
- updateProgress(fileSizeMap[path]),
- return)
+ SPECIAL_COPY_ERROR_PROMPT(engine.isSequential(), tr("Cannot copy sequential file %1."), path)
if (newFile.exists() && newFile.isDir()) {
if (newFile.exists() && newFile.isDir()) {
- ERROR_PROMPT_XP(!remove(newPath),
- tr("Cannot replace directory %1 due to previous errors."), newPath,
- updateProgress(fileSizeMap[path]),
- return)
+ SPECIAL_COPY_ERROR_PROMPT(!remove(newPath),
+ tr("Cannot replace directory %1 due to previous errors."), newPath)
- ERROR_PROMPT_XP(!engine.open(QIODevice::ReadOnly),
- tr("Error reading file %1."), path,
- updateProgress(fileSizeMap[path]),
- return)
+ SPECIAL_COPY_ERROR_PROMPT(!engine.open(QIODevice::ReadOnly), tr("Error reading file %1."), path)
bool ignore = false;
while (!abort && !ignore) {
engine.seek(0);
bool ignore = false;
while (!abort && !ignore) {
engine.seek(0);
ERROR_PROMPT(!newEngine.open(QIODevice::WriteOnly | QIODevice::Truncate),
tr("Error writing file %1."), newPath)
if (abort || response == FileOperator::IGNORE) {
if (response == FileOperator::IGNORE) {
ERROR_PROMPT(!newEngine.open(QIODevice::WriteOnly | QIODevice::Truncate),
tr("Error writing file %1."), newPath)
if (abort || response == FileOperator::IGNORE) {
if (response == FileOperator::IGNORE) {
- updateProgress(fileSizeMap[path] - fileValue);
+ updateProgress(fileSizeMap[path]);
+ removeExcludeFiles.insert(path);
if (!abort) {
if (response == FileOperator::IGNORE) {
updateProgress(fileSizeMap[path] - fileValue);
if (!abort) {
if (response == FileOperator::IGNORE) {
updateProgress(fileSizeMap[path] - fileValue);
+ removeExcludeFiles.insert(path);
ignore = true;
} else {
updateProgress(-fileValue);
ignore = true;
} else {
updateProgress(-fileValue);
OVERWRITE_PROMPT(files[i], QFileInfo(newPath))
if (response == FileOperator::KEEP) {
OVERWRITE_PROMPT(files[i], QFileInfo(newPath))
if (response == FileOperator::KEEP) {
- // TODO lets not remove the source for now, I'm not sure what is correct behavior
- // remove(path);
if (abort) break;
updateProgress(1);
continue;
if (abort) break;
updateProgress(1);
continue;
#include <QWaitCondition>
#include <QDir>
#include <QMap>
#include <QWaitCondition>
#include <QDir>
#include <QMap>
class FileManipulatorThread;
class FileManipulatorThread;
bool abort;
bool ignoreAll[256];
bool abort;
bool ignoreAll[256];
+ // set of files that won't be deleted by the remove(...) functions
+ // used when move(...) would not overwrite target file to ensure the source file doesn't get deleted
+ QSet<QString> removeExcludeFiles;
+
QMap<QString, qint64> fileSizeMap;
QMutex mutex;
QMap<QString, qint64> fileSizeMap;
QMutex mutex;