FileMode/FileOption debugging, fixes, and added safety.

This commit is contained in:
J-D-K
2025-09-06 19:21:35 -04:00
parent f052d0b2a7
commit e1d592ee9c
44 changed files with 208 additions and 151 deletions

View File

@@ -11,6 +11,7 @@ void tasks::fileoptions::copy_source_to_destination(sys::ProgressTask *task, Fil
{
if (error::is_null(task)) { return; }
const int popTicks = ui::PopMessageManager::DEFAULT_TICKS;
const fslib::Path &source = taskData->sourcePath;
const fslib::Path &dest = taskData->destPath;
const int64_t journalSpace = taskData->journalSize;
@@ -29,7 +30,13 @@ void tasks::fileoptions::copy_source_to_destination(sys::ProgressTask *task, Fil
}
}
if (destError) { TASK_FINISH_RETURN(task); }
if (destError)
{
const char *errorFormat = strings::get_by_name(strings::names::FILEOPTION_POPS, 0);
const std::string pop = stringutil::get_formatted_string(errorFormat, source.get_filename());
ui::PopMessageManager::push_message(popTicks, pop);
TASK_FINISH_RETURN(task);
}
const bool needsCommit = journalSpace > 0;
@@ -47,7 +54,9 @@ void tasks::fileoptions::delete_target(sys::Task *task, FileOptionState::TaskDat
if (error::is_null(task)) { return; }
// Gonna borrow this. No point in duplicating it.
const int popTicks = ui::PopMessageManager::DEFAULT_TICKS;
const char *deletingFormat = strings::get_by_name(strings::names::IO_STATUSES, 3);
const char *errorFormat = strings::get_by_name(strings::names::FILEOPTION_POPS, 1);
const fslib::Path &target = taskData->sourcePath;
const int64_t journalSpace = taskData->journalSize;
@@ -62,10 +71,24 @@ void tasks::fileoptions::delete_target(sys::Task *task, FileOptionState::TaskDat
const bool isDir = fslib::directory_exists(target);
bool needsCommit = journalSpace > 0;
if (isDir) { fslib::delete_directory_recursively(target); }
else { fslib::delete_file(target); }
bool deleteError{};
if (isDir) { deleteError = error::fslib(fslib::delete_directory_recursively(target)); }
else { deleteError = error::fslib(fslib::delete_file(target)); }
if (needsCommit) { fslib::commit_data_to_file_system(target.get_device_name()); }
if (deleteError)
{
const char *filename = target.get_filename();
const std::string pop = stringutil::get_formatted_string(errorFormat, filename);
ui::PopMessageManager::push_message(popTicks, pop);
}
const bool commitError = needsCommit && error::fslib(fslib::commit_data_to_file_system(target.get_device_name()));
if (commitError)
{
const char *filename = target.get_filename();
const std::string pop = stringutil::get_formatted_string(errorFormat, filename);
ui::PopMessageManager::push_message(popTicks, pop);
}
spawningState->update_source();
task->complete();