Filemanager improved error handling#1710
Conversation
cc3f990 to
623d411
Compare
If you opened the backup, saved and the project corrupted, a backup wouldn't be made. The file would instead be renamed.
623d411 to
0de72ae
Compare
| const bool isOldType = sFileName.endsWith(PFF_OLD_EXTENSION); | ||
| if (isOldType) | ||
| Status isArchiveSt = isArchiveFormat(sFileName); | ||
| if (isArchiveSt == Status::NOT_ARCHIVE_FORMAT) |
There was a problem hiding this comment.
It's a bit weird to use Status in this way instead of reporting errors. Probably keep the old bool return value?
The function isArchiveFormat() returns only two values: OK or NOT_ARCHIVE_FORMAT and doesn't have any error handling things.
There was a problem hiding this comment.
You're right.. previously I was using the sanity check function, and used the Status details to enrich the error report but since we don't do that anymore, there's no need to use Status, I will change that
| QDir directory(info.absoluteDir()); | ||
| QString backupString = "backup"; | ||
| for (QFileInfo info : directory.entryInfoList(QDir::Filter::Files)) { | ||
| if (info.completeBaseName().contains(backupString)) { |
There was a problem hiding this comment.
The word "backup" is commonly used in terms of file naming. Chances are that users will use "backup" in their filename and then the backupCount number would be wrong.
I would suggest to check with full filenames such as sBackupFile below to get a correct backup count.
There was a problem hiding this comment.
Ah.. good point, I forgot about that! will fix.
| } | ||
| } | ||
|
|
||
| QString sBackupFile = info.baseName() + "." + backupString + QString::number(backupCount) + "." + info.suffix(); |
There was a problem hiding this comment.
completeBaseName() instead of baseName()? Just in case there are dots in filenames.
|
Thanks @MrStevns! I think generally it's good. It can be merged after some minor improvements as comments. |
113b84c to
2526ce5
Compare
This PR makes a few changes to the filemanager, improving the error handling and fixing a few situations where the project could be corrupted and a backup wouldn't be made.