MassManager: fix bugs in path handling.

This commit is contained in:
Guillaume Jacquemin 2021-11-01 09:40:33 +01:00
parent 8d87cdd619
commit 83fa5822bf

View file

@ -86,8 +86,8 @@ auto MassManager::importMass(const std::string& staged_fn, int hangar) -> bool {
return false;
}
if(Utility::Directory::exists(_hangars[hangar].filename())) {
Utility::Directory::rm(_hangars[hangar].filename());
if(Utility::Directory::exists(Utility::Directory::join(_saveDirectory, _hangars[hangar].filename()))) {
Utility::Directory::rm(Utility::Directory::join(_saveDirectory, _hangars[hangar].filename()));
}
if(!Utility::Directory::move(source + ".tmp", Utility::Directory::join(_saveDirectory, _hangars[hangar].filename()))) {
@ -132,8 +132,8 @@ auto MassManager::moveMass(int source, int destination) -> bool {
return false;
}
std::string source_file = _hangars[source].filename();
std::string dest_file = _hangars[destination].filename();
std::string source_file = Utility::Directory::join(_saveDirectory, _hangars[source].filename());
std::string dest_file = Utility::Directory::join(_saveDirectory, _hangars[destination].filename());
Mass::State dest_state = _hangars[destination].state();
switch(dest_state) {
@ -162,7 +162,7 @@ auto MassManager::deleteMass(int hangar) -> bool {
return false;
}
if(!Utility::Directory::rm(_hangars[hangar].filename())) {
if(!Utility::Directory::rm(Utility::Directory::join(_saveDirectory, _hangars[hangar].filename()))) {
_lastError = "Deletion failed. Maybe the file was already deleted, or it's locked by another application.";
return false;
}