Skip to content

Commit 1ccc81d

Browse files
committed
Postfix for #8588: Error doing nbackup when Database file name has extended ASCII chars; centralize conversion from utf8 & apply it to decompress command too
1 parent 5a4f245 commit 1ccc81d

File tree

1 file changed

+17
-14
lines changed

1 file changed

+17
-14
lines changed

src/utilities/nbackup/nbackup.cpp

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -298,9 +298,8 @@ class NBackup
298298
pr_error(status, "nbackup needs local access to database file");
299299
}
300300

301-
if (uSvc->utf8FileNames())
302-
ISC_utf8ToSystem(db);
303-
301+
toSystem(decompress);
302+
toSystem(db);
304303
expandDatabaseName(db, dbname, NULL);
305304

306305
if (!uSvc->isService())
@@ -371,7 +370,7 @@ class NBackup
371370
void internal_unlock_database();
372371
void attach_database();
373372
void detach_database();
374-
string to_system(const PathName& from);
373+
void toSystem(AbstractString& from);
375374
void cleanHistory();
376375

377376
// Create/open database and backup
@@ -600,12 +599,10 @@ void NBackup::close_database()
600599
dbase = INVALID_HANDLE_VALUE;
601600
}
602601

603-
string NBackup::to_system(const PathName& from)
602+
void NBackup::toSystem(AbstractString& from)
604603
{
605-
string to = from.ToString();
606604
if (uSvc->utf8FileNames())
607-
ISC_utf8ToSystem(to);
608-
return to;
605+
ISC_utf8ToSystem(from);
609606
}
610607

611608

@@ -617,14 +614,13 @@ void NBackup::open_backup_scan()
617614
return;
618615
}
619616

620-
string nm = to_system(bakname);
621617
#ifdef WIN_NT
622-
backup = CreateFile(nm.c_str(), GENERIC_READ, 0,
618+
backup = CreateFile(bakname.c_str(), GENERIC_READ, 0,
623619
NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, NULL);
624620
if (backup != INVALID_HANDLE_VALUE)
625621
return;
626622
#else
627-
backup = os_utils::open(nm.c_str(), O_RDONLY | O_LARGEFILE);
623+
backup = os_utils::open(bakname.c_str(), O_RDONLY | O_LARGEFILE);
628624
if (backup >= 0)
629625
return;
630626
#endif
@@ -772,7 +768,6 @@ void NBackup::open_backup_decompress()
772768

773769
void NBackup::create_backup()
774770
{
775-
string nm = to_system(bakname);
776771
#ifdef WIN_NT
777772
if (bakname == "stdout") {
778773
backup = GetStdHandle(STD_OUTPUT_HANDLE);
@@ -787,7 +782,7 @@ void NBackup::create_backup()
787782
// avoids an issue where writing to a file across a network can occasionally
788783
// return ERROR_ACCESS_DENIED.
789784

790-
backup = CreateFile(nm.c_str(), GENERIC_READ | GENERIC_WRITE, FILE_SHARE_DELETE,
785+
backup = CreateFile(bakname.c_str(), GENERIC_READ | GENERIC_WRITE, FILE_SHARE_DELETE,
791786
NULL, CREATE_NEW, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, NULL);
792787
}
793788
if (backup != INVALID_HANDLE_VALUE)
@@ -798,7 +793,7 @@ void NBackup::create_backup()
798793
backup = 1; // Posix file handle for stdout
799794
return;
800795
}
801-
backup = os_utils::open(nm.c_str(), O_WRONLY | O_CREAT | O_EXCL | O_LARGEFILE, 0660);
796+
backup = os_utils::open(bakname.c_str(), O_WRONLY | O_CREAT | O_EXCL | O_LARGEFILE, 0660);
802797
if (backup >= 0)
803798
return;
804799
#endif
@@ -1301,7 +1296,10 @@ void NBackup::backup_database(int level, const string& guidStr, const PathName&
13011296
detach_database();
13021297

13031298
if (fname.hasData())
1299+
{
13041300
bakname = fname;
1301+
toSystem(bakname);
1302+
}
13051303
else
13061304
{
13071305
// Let's generate nice new filename
@@ -1694,6 +1692,8 @@ void NBackup::restore_database(const BackupFiles& files, bool repl_seq, bool inc
16941692
fixup_database(repl_seq);
16951693
return;
16961694
}
1695+
toSystem(bakname);
1696+
16971697
// Never reaches this point when run as service
16981698
try {
16991699
fb_assert(!uSvc->isService());
@@ -1727,7 +1727,10 @@ void NBackup::restore_database(const BackupFiles& files, bool repl_seq, bool inc
17271727
return;
17281728
}
17291729
if (!inc_rest || curLevel)
1730+
{
17301731
bakname = files[curLevel - (inc_rest ? 1 : 0)];
1732+
toSystem(bakname);
1733+
}
17311734
if (!inc_rest || curLevel)
17321735
open_backup_scan();
17331736
}

0 commit comments

Comments
 (0)