mirror of
https://github.com/cookiengineer/audacity
synced 2025-06-25 16:48:44 +02:00
Proper deferring of DirManager's commit steps when saving-as
This commit is contained in:
parent
ec506ab52b
commit
e87e15f489
@ -3959,11 +3959,13 @@ bool AudacityProject::DoSave (const bool fromSaveAs,
|
|||||||
if (!success)
|
if (!success)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
Maybe<DirManager::ProjectSetter> pSetter;
|
||||||
|
|
||||||
if (fromSaveAs && !bWantSaveCopy) {
|
if (fromSaveAs && !bWantSaveCopy) {
|
||||||
// We are about to move files from the current directory to
|
// We are about to move files from the current directory to
|
||||||
// the NEW directory. We need to make sure files that belonged
|
// the NEW directory. We need to make sure files that belonged
|
||||||
// to the last saved project don't get erased, so we "lock" them, so that
|
// to the last saved project don't get erased, so we "lock" them, so that
|
||||||
// SetProject() copies instead of moves the files.
|
// ProjectSetter's constructor copies instead of moves the files.
|
||||||
// (Otherwise the NEW project would be fine, but the old one would
|
// (Otherwise the NEW project would be fine, but the old one would
|
||||||
// be empty of all of its files.)
|
// be empty of all of its files.)
|
||||||
|
|
||||||
@ -3977,19 +3979,17 @@ bool AudacityProject::DoSave (const bool fromSaveAs,
|
|||||||
|
|
||||||
// This renames the project directory, and moves or copies
|
// This renames the project directory, and moves or copies
|
||||||
// all of our block files over.
|
// all of our block files over.
|
||||||
success = mDirManager->SetProject(projPath, projName, true);
|
pSetter.create( *mDirManager, projPath, projName, true );
|
||||||
|
|
||||||
if (!success)
|
if (!pSetter->Ok())
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Commit the writing of the .aup only now, after we know that the _data
|
// Commit the writing of the .aup only now, after we know that the _data
|
||||||
// folder also saved with no problems.
|
// folder also saved with no problems.
|
||||||
// Error recovery in case this fails might not be correct -- there is no
|
// It is very unlikely that errors will happen:
|
||||||
// provision to undo the effects of SetProject -- but it is very unlikely
|
// only renaming and removing of files, not writes that might exhaust space.
|
||||||
// that this will happen: only renaming and removing of files happens,
|
// So DO give a second dialog in case the unusual happens.
|
||||||
// not writes that might exhaust space. So DO give a second dialog in
|
|
||||||
// case the unusual happens.
|
|
||||||
success = success && GuardedCall< bool >( [&] {
|
success = success && GuardedCall< bool >( [&] {
|
||||||
saveFile.PostCommit();
|
saveFile.PostCommit();
|
||||||
return true;
|
return true;
|
||||||
@ -4000,6 +4000,9 @@ bool AudacityProject::DoSave (const bool fromSaveAs,
|
|||||||
|
|
||||||
// SAVE HAS SUCCEEDED -- following are further no-fail commit operations.
|
// SAVE HAS SUCCEEDED -- following are further no-fail commit operations.
|
||||||
|
|
||||||
|
if (pSetter)
|
||||||
|
pSetter->Commit();
|
||||||
|
|
||||||
if ( !bWantSaveCopy )
|
if ( !bWantSaveCopy )
|
||||||
{
|
{
|
||||||
// Now that we have saved the file, we can DELETE the auto-saved version
|
// Now that we have saved the file, we can DELETE the auto-saved version
|
||||||
|
Loading…
x
Reference in New Issue
Block a user