M
M
Mercury132021-10-18 23:44:59
Access rights
Mercury13, 2021-10-18 23:44:59

How to combine smart file overwriting with permissions?

There is a program (it doesn't matter which one). You need to save the document file to disk. I found myself between two fires.
1. Take and overwrite - in case of any glitch, both the program and the storage system, even if there is not enough disk space, the file will disappear.
2. Create a project file from scratch, and if the recording succeeds, delete the old one and rename the new one - access rights are lost.

How to proceed? What are the standard ways to resolve this contradiction?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
N
nApoBo3, 2021-10-19
@nApoBo3

And this is one of the reasons why you need to think 1000 times before giving rights to a separate file, the rights to the file should be inherited from the directory. There is no way to solve this systemically, your program may simply not have permissions to delete the source file and even to read its permissions. Write the requirements for access rights in the documentation and let the admins deal with their zoo themselves.

S
Saboteur, 2021-10-19
@saboteur_kiev

As an option - copy the previous document to a temporary file, and then overwrite the current file. If the operation is successful, then delete the temporary file. If the operation is not successful, then either restore the data from a temporary file, or if the program crashes, the disk will have the previous document in another file (yes, with different rights, but it will).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question