mirror of
https://github.com/J-D-K/JKSV.git
synced 2026-08-21 18:05:23 -05:00
FileMode/FileOption debugging, fixes, and added safety.
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user