Commit 538f9d18 authored by Urs Fleisch's avatar Urs Fleisch
Browse files

Revert file name modification if tagged file is not writable.

Changing the permissions does not work if both the tags and
the file name are changed on a read-only file. In such a case
the changed file name is reverted so that changing the
permissions and saving the changed tags will work. The file
name change is lost, but this is less severe than losing all
tag changes.
parent e105eb1c
......@@ -343,6 +343,15 @@ void TaggedFile::markFilenameUnchanged()
updateModifiedState();
}
/**
* Revert modification of filename.
*/
void TaggedFile::revertChangedFilename()
{
m_newFilename = m_filename;
updateModifiedState();
}
/**
* Mark tag 1 as changed.
*
......
......@@ -778,6 +778,11 @@ protected:
*/
void markFilenameUnchanged();
/**
* Revert modification of filename.
*/
void revertChangedFilename();
/**
* Check if tag 1 was changed.
* @return true if tag 1 was changed.
......
......@@ -174,6 +174,7 @@ bool Mp3File::writeTags(bool force, bool* renamed, bool preserve)
{
QString fnStr(currentFilePath());
if (isChanged() && !QFileInfo(fnStr).isWritable()) {
revertChangedFilename();
return false;
}
......
......@@ -597,6 +597,7 @@ bool M4aFile::writeTags(bool force, bool* renamed, bool preserve)
bool ok = true;
QString fnStr(currentFilePath());
if (isChanged() && !QFileInfo(fnStr).isWritable()) {
revertChangedFilename();
return false;
}
......
......@@ -237,6 +237,7 @@ bool FlacFile::writeTags(bool force, bool* renamed, bool preserve)
{
if (isChanged() &&
!QFileInfo(currentFilePath()).isWritable()) {
revertChangedFilename();
return false;
}
......
......@@ -247,6 +247,7 @@ bool OggFile::writeTags(bool force, bool* renamed, bool preserve)
QString dirname = getDirname();
if (isChanged() &&
!QFileInfo(currentFilePath()).isWritable()) {
revertChangedFilename();
return false;
}
......
......@@ -1013,6 +1013,7 @@ bool TagLibFile::writeTags(bool force, bool* renamed, bool preserve,
#if TAGLIB_VERSION >= 0x010800
closeFile(false);
#endif
revertChangedFilename();
return false;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment