Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
F
FOSS-2024-1-final
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
AudacityFontProject
FOSS-2024-1-final
Commits
7eeb8838
Commit
7eeb8838
authored
7 years ago
by
Paul Licameli
Browse files
Options
Downloads
Patches
Plain Diff
Compensate for bug in wxCopyFile, which can return incorrect success
parent
985457e9
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/DirManager.cpp
+31
-3
31 additions, 3 deletions
src/DirManager.cpp
with
31 additions
and
3 deletions
src/DirManager.cpp
+
31
−
3
View file @
7eeb8838
...
...
@@ -1161,6 +1161,34 @@ bool DirManager::ContainsBlockFile(const wxString &filepath) const
BlockFilePtr
{
it
->
second
.
lock
()
};
}
namespace
{
bool
MyCopyFile
(
const
wxString
&
file1
,
const
wxString
&
file2
,
bool
overwrite
=
true
)
{
#ifdef __WXMSW__
// workaround not needed
return
wxCopyFile
(
file1
,
file2
,
overwrite
);
#else
// PRL: Compensate for buggy wxCopyFile that returns false success,
// which was a cause of case 4 in comment 10 of
// http://bugzilla.audacityteam.org/show_bug.cgi?id=1759
// Destination file was created, but was empty
// Bug was introduced after wxWidgets 2.8.12 at commit
// 0597e7f977c87d107e24bf3e95ebfa3d60efc249 of wxWidgets repo
bool
existed
=
wxFileExists
(
file2
);
bool
result
=
wxCopyFile
(
file1
,
file2
,
overwrite
)
&&
wxFile
{
file1
}.
Length
()
==
wxFile
{
file2
}.
Length
();
if
(
!
result
&&
!
existed
)
wxRemoveFile
(
file2
);
return
result
;
#endif
}
}
// Adds one to the reference count of the block file,
// UNLESS it is "locked", then it makes a NEW copy of
// the BlockFile.
...
...
@@ -1204,7 +1232,7 @@ BlockFilePtr DirManager::CopyBlockFile(const BlockFilePtr &b)
//a summary file, so we should check before we copy.
if
(
b
->
IsSummaryAvailable
())
{
if
(
!
wx
CopyFile
(
fn
.
GetFullPath
(),
if
(
!
My
CopyFile
(
fn
.
GetFullPath
(),
newFile
.
GetFullPath
())
)
// Disk space exhaustion, maybe
throw
FileException
{
...
...
@@ -1351,7 +1379,7 @@ std::pair<bool, wxString> DirManager::CopyToNewProjectDirectory(BlockFile *f)
auto
oldPath
=
oldFileNameRef
.
GetFullPath
();
newPath
=
newFileName
.
GetFullPath
();
if
(
summaryExisted
)
{
auto
success
=
wx
CopyFile
(
oldPath
,
newPath
);
auto
success
=
My
CopyFile
(
oldPath
,
newPath
);
if
(
!
success
)
return
{
false
,
{}
};
}
...
...
@@ -1382,7 +1410,7 @@ std::pair<bool, wxString> DirManager::CopyToNewProjectDirectory(BlockFile *f)
//if it doesn't, we can assume it was written to the NEW name, which is fine.
if
(
oldFileName
.
FileExists
())
{
bool
ok
=
wx
CopyFile
(
oldPath
,
newPath
);
bool
ok
=
My
CopyFile
(
oldPath
,
newPath
);
if
(
!
ok
)
return
{
false
,
{}
};
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment