Consider the following sequence of actions:
- I instruct a program to open a file,
- (I modify the file in the program, and save it to the file. )
- I
mv
the file elsewhere. For example, the file was originallydir1/dir2/dir3/all.pdf
, and then I ranmv dir1/dir2/dir3 dir1/; rmdir dir1/dir2
. Now the file isdir1/dir3/all.pdf
. - I modify the file in the program
- I instruct the program to save the modified to the new location of the file, via "save as ...".
Is whether "save as ..." with file moving succeeds or fails up to the program? For example,
- when the program is PDFXCView run under wine 3.0 and Ubuntu 18.04, it made a pdf file disappear and aborted its own process, when "save as...".
- Can a program native to Linux fail "save as ..." and lose the file, or fail "save as..." and keep the file intact, or succeed in "save as ..."?
While another program moves files, what does a program need to do to save changes to the files successfully (either to the new location or the original one)?
Does the OS or filesystem not be able to warn or prevent such cases from happening?
What can we do to avoid or reduce the likelihood of data loss, in such cases, regardless of which program, OS or filesystem?
Thanks.