mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-09 18:31:04 +00:00
Keep permissions of the saved files intact.
Previously the permission were destroyed by the newly created temporary file -- which is later used as new saved file. Tested on symlinks as well but only on Linux.
This commit is contained in:
parent
32c6724fd6
commit
04fe818b22
@ -1443,6 +1443,9 @@ bool Buffer::save() const
|
||||
|
||||
FileName savefile(tempfile->name());
|
||||
LYXERR(Debug::FILES, "Saving to " << savefile.absFileName());
|
||||
if (!savefile.clonePermissions(fileName()))
|
||||
LYXERR0("Failed to clone the permission from " << fileName().absFileName() << " to " << savefile.absFileName());
|
||||
|
||||
if (!writeFile(savefile))
|
||||
return false;
|
||||
|
||||
|
@ -288,6 +288,13 @@ bool FileName::changePermission(unsigned long int mode) const
|
||||
return true;
|
||||
}
|
||||
|
||||
bool FileName::clonePermissions(FileName const & source)
|
||||
{
|
||||
QFile fin(toqstr(source.absFileName()));
|
||||
QFile f(toqstr(absFileName()));
|
||||
|
||||
return f.setPermissions(fin.permissions());
|
||||
}
|
||||
|
||||
string FileName::toFilesystemEncoding() const
|
||||
{
|
||||
|
@ -150,6 +150,8 @@ public:
|
||||
/// support this.
|
||||
/// \return true on success.
|
||||
bool changePermission(unsigned long int mode) const;
|
||||
// sets permission based on the file given as an argument
|
||||
bool clonePermissions(FileName const & target);
|
||||
|
||||
/// remove pointed directory and all contents.
|
||||
/// \return true on success.
|
||||
|
Loading…
Reference in New Issue
Block a user