Skip to content

Commit

Permalink
Added more checking and verbose messages to image versioning.
Browse files Browse the repository at this point in the history
  • Loading branch information
ggarra13 committed Dec 17, 2024
1 parent 2d58943 commit 41e9ec6
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 6 deletions.
5 changes: 5 additions & 0 deletions src/lib/mrvCore/mrvFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,11 @@ namespace mrv
return fs::is_directory(dir);
}

bool exists(const fs::path& filePath)
{
return fs::exists(filePath);
}

bool isReadable(const fs::path& p)
{
const std::string& filePath = p.generic_string();
Expand Down
9 changes: 9 additions & 0 deletions src/lib/mrvCore/mrvFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,15 @@ namespace mrv
*/
bool isDirectory(const std::string& directory);

/**
* Return true if the file exists and is readable
*
* @param p std::filesystem path (or std::string).
*
* @return true if it exists and is readable, false if not.
*/
bool exists(const fs::path& path);

/**
* Return true if the file exists and is readable
*
Expand Down
45 changes: 39 additions & 6 deletions src/lib/mrvFl/mrvVersioning.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ namespace mrv

std::string msg;
std::string file = path.get();
replace_path(file);

while ((first_or_last || found == false) &&
tries <= max_tries)
Expand Down Expand Up @@ -146,12 +145,46 @@ namespace mrv

newfile += suffix;

if (file::isReadable(newfile))

if (file::isNetwork(newfile))
{
msg = tl::string::Format(_("File {0} is a network file. "
"Cannot do versioning."))
.arg(newfile);
LOG_ERROR(msg);
return file;
}


if (file::exists(newfile))
{
msg = tl::string::Format(
_("Found new versioned file {0}."))
.arg(newfile);
LOG_INFO(msg);

if (file::isReadable(newfile))
{
loadfile = newfile;
found = true;
if (!first_or_last)
break;
}
else
{
msg = tl::string::Format(
_("File {0} found but is not readable."))
.arg(newfile);
LOG_ERROR(msg);
return file;
}
}
else
{
loadfile = newfile;
found = true;
if (!first_or_last)
break;
msg = tl::string::Format(
_("Did not find new versioned file {0}."))
.arg(newfile);
LOG_INFO(msg);
}

file = newfile;
Expand Down

0 comments on commit 41e9ec6

Please sign in to comment.