« first day (3329 days earlier)      last day (1623 days later) » 

8:00 PM
@Wietlol s/copy/write/
 
var path = "/path/to/file.sav";
var temp = "/path/to/newfile.sav";

var current = path

await Write(temp);

current = temp;

// perhaps delete 'path' first
await Copy(from = temp, to = path);

current = path;

await Delete(temp);
current always points to the location of a valid file
 
@Wietlol Sure, but that's twice the I/O
To be fair, if you just change Copy to Rename, you get my solution
 
but it is pretty failsafe
I prefer more IO if it means more logical guarantees of recoverability
rename might be atomic, but that is an implementation detail
 
@Wietlol I'm not sure users would appreciate waiting twice as long for their save operation to go through
You're talking about img files which could get... big.
 
true, a rename could be O(1)
and copy is O(n)
but after the write, you dont need a static state any more
 
8:04 PM
It's O(n) either way
 
the lines below current = temp; can be a background task
 
But it's one of those cases where the difference between a*n and a*2*n might be very significant :D
 
ye, I mean only the rename vs copy+delete
that is O(1) vs O(n)
 
anyway...
back to botting
 

« first day (3329 days earlier)      last day (1623 days later) »