diff options
Diffstat (limited to 'src/utils/cpp/file_locking.cpp')
-rw-r--r-- | src/utils/cpp/file_locking.cpp | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/src/utils/cpp/file_locking.cpp b/src/utils/cpp/file_locking.cpp index 3868af1b..c633b32b 100644 --- a/src/utils/cpp/file_locking.cpp +++ b/src/utils/cpp/file_locking.cpp @@ -80,15 +80,26 @@ auto LockFile::GetLockFilePath(std::filesystem::path const& fspath) noexcept -> std::optional<std::filesystem::path> { try { // bring to normal form - auto abs_fspath = ToNormalPath(std::filesystem::absolute(fspath)); - auto filename = abs_fspath.filename(); - auto parent = abs_fspath.parent_path(); + auto filename = ToNormalPath(fspath); + if (not filename.is_absolute()) { + try { + filename = std::filesystem::absolute(fspath); + } catch (std::exception const& e) { + Logger::Log(LogLevel::Error, + "Failed to determine absolute path for lock file " + "name {}: {}", + fspath.string(), + e.what()); + return std::nullopt; + } + } + auto parent = filename.parent_path(); // create parent folder if (not FileSystemManager::CreateDirectory(parent)) { return std::nullopt; } - // get lock file name - return parent / filename; + // return lock file name + return filename; } catch (std::exception const& ex) { Logger::Log( LogLevel::Error, |