Savestates/sys_fs: Fix saving encrypted and split-files file descriptors

This commit is contained in:
Eladash 2022-08-25 10:53:35 +03:00 committed by kd-11
parent 506b9deec5
commit c7586de280
1 changed files with 23 additions and 3 deletions

View File

@ -313,7 +313,7 @@ void lv2_file::save(utils::serial& ar)
}
// UNIX allows deletion of files while descriptors are still opened
// descriptpors shall keep the data in memory in this case
// descriptors shall keep the data in memory in this case
const bool in_mem = [&]()
{
if (mp->flags & lv2_mp_flag::read_only)
@ -323,11 +323,31 @@ void lv2_file::save(utils::serial& ar)
fs::file test{real_path};
if (!test) return true;
if (!test)
{
if (fs::is_file(real_path + ".66600"))
{
// May be a split-files descriptor, don't even bother
return false;
}
return test.stat() != file.stat();
return true;
}
fs::stat_t test_s = test.stat();
fs::stat_t file_s = file.stat();
// They don't matter for comparison and only create problems with encrypted files
test_s.is_writable = file_s.is_writable;
test_s.size = file_s.size;
return test_s != file_s;
}();
if (in_mem)
{
sys_fs.error("Saving \'%s\' LV2 file descriptor in memory! (exists=%s, type=%s, flags=0x%x)", name.data(), fs::is_file(real_path), type, flags);
}
ar(in_mem);
if (in_mem)