mirror of
https://github.com/cookiengineer/audacity
synced 2025-08-01 08:29:27 +02:00
Bug 328 (P2) - do not allow writing to paths that are also missing alias files.
This commit is contained in:
parent
3a7d00394f
commit
26c84929a6
@ -38,23 +38,6 @@
|
|||||||
#include "ShuttleGui.h"
|
#include "ShuttleGui.h"
|
||||||
#include "Track.h"
|
#include "Track.h"
|
||||||
|
|
||||||
|
|
||||||
class AliasedFile
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
AliasedFile(wxFileName fileName, wxLongLong byteCount, bool bOriginalExists)
|
|
||||||
{
|
|
||||||
mFileName = fileName;
|
|
||||||
mByteCount = byteCount;
|
|
||||||
mbOriginalExists = bOriginalExists;
|
|
||||||
};
|
|
||||||
wxFileName mFileName;
|
|
||||||
wxLongLong mByteCount; // if stored as current default sample format
|
|
||||||
bool mbOriginalExists;
|
|
||||||
};
|
|
||||||
|
|
||||||
WX_DECLARE_OBJARRAY(AliasedFile, AliasedFileArray);
|
|
||||||
|
|
||||||
// Note, this #include must occur here, not up with the others!
|
// Note, this #include must occur here, not up with the others!
|
||||||
// It must be between the WX_DECLARE_OBJARRAY and WX_DEFINE_OBJARRAY.
|
// It must be between the WX_DECLARE_OBJARRAY and WX_DEFINE_OBJARRAY.
|
||||||
#include <wx/arrimpl.cpp>
|
#include <wx/arrimpl.cpp>
|
||||||
|
@ -14,8 +14,27 @@
|
|||||||
#ifndef __AUDACITY_DEPENDENCIES__
|
#ifndef __AUDACITY_DEPENDENCIES__
|
||||||
#define __AUDACITY_DEPENDENCIES__
|
#define __AUDACITY_DEPENDENCIES__
|
||||||
|
|
||||||
|
#include <wx/dynarray.h>
|
||||||
|
|
||||||
class AudacityProject;
|
class AudacityProject;
|
||||||
|
|
||||||
|
class AliasedFile
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
AliasedFile(wxFileName fileName, wxLongLong byteCount, bool bOriginalExists)
|
||||||
|
{
|
||||||
|
mFileName = fileName;
|
||||||
|
mByteCount = byteCount;
|
||||||
|
mbOriginalExists = bOriginalExists;
|
||||||
|
};
|
||||||
|
wxFileName mFileName;
|
||||||
|
wxLongLong mByteCount; // if stored as current default sample format
|
||||||
|
bool mbOriginalExists;
|
||||||
|
};
|
||||||
|
|
||||||
|
WX_DECLARE_OBJARRAY(AliasedFile, AliasedFileArray);
|
||||||
|
|
||||||
|
|
||||||
// Checks for alias block files, modifies the project if the
|
// Checks for alias block files, modifies the project if the
|
||||||
// user requests it, and returns True if the user continues.
|
// user requests it, and returns True if the user continues.
|
||||||
// Returns false if the user clicks Cancel, meaning that they do
|
// Returns false if the user clicks Cancel, meaning that they do
|
||||||
@ -23,4 +42,8 @@ class AudacityProject;
|
|||||||
bool ShowDependencyDialogIfNeeded(AudacityProject *project,
|
bool ShowDependencyDialogIfNeeded(AudacityProject *project,
|
||||||
bool isSaving);
|
bool isSaving);
|
||||||
|
|
||||||
|
// Returns a list of aliased files associated with a project.
|
||||||
|
void FindDependencies(AudacityProject *project,
|
||||||
|
AliasedFileArray *outAliasedFiles);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -73,6 +73,7 @@
|
|||||||
#include "../widgets/Warning.h"
|
#include "../widgets/Warning.h"
|
||||||
#include "../AColor.h"
|
#include "../AColor.h"
|
||||||
#include "../TimeTrack.h"
|
#include "../TimeTrack.h"
|
||||||
|
#include "../Dependencies.h"
|
||||||
|
|
||||||
// Callback to display format options
|
// Callback to display format options
|
||||||
static void ExportCallback(void *cbdata, int index)
|
static void ExportCallback(void *cbdata, int index)
|
||||||
@ -635,6 +636,29 @@ bool Exporter::GetFilename()
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check to see if we are writing to a path that a missing aliased file existed at.
|
||||||
|
// This causes problems for the exporter, so we don't allow it.
|
||||||
|
// Overwritting non-missing aliased files is okay.
|
||||||
|
// Also, this can only happen for uncompressed audio.
|
||||||
|
size_t i;
|
||||||
|
bool overwritingMissingAlias;
|
||||||
|
overwritingMissingAlias = false;
|
||||||
|
for (size_t i = 0; i < gAudacityProjects.GetCount(); i++) {
|
||||||
|
AliasedFileArray aliasedFiles;
|
||||||
|
FindDependencies(gAudacityProjects[i], &aliasedFiles);
|
||||||
|
if (mFilename.GetFullPath() == aliasedFiles[i].mFileName.GetFullPath() &&
|
||||||
|
!mFilename.FileExists()) {
|
||||||
|
// Warn and return to the dialog
|
||||||
|
wxMessageBox(_("You are attempting to overwrite an aliased file that is missing.\n\
|
||||||
|
The file cannot be written because the path is needed to restore the original audio to the project.\n\
|
||||||
|
You can see the missing files in File > Check Dependencies.\n\
|
||||||
|
If you still wish to export, please choose a different filename."));
|
||||||
|
overwritingMissingAlias = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (overwritingMissingAlias)
|
||||||
|
continue;
|
||||||
|
|
||||||
if (mFilename.FileExists()) {
|
if (mFilename.FileExists()) {
|
||||||
wxString prompt;
|
wxString prompt;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user