mirror of
https://github.com/borgbackup/borg.git
synced 2025-03-15 00:21:56 +00:00
explicitely specify binary mode to open binary files
on POSIX OSes, it doesn't make a difference, but it is cleaner and also good for portability.
This commit is contained in:
parent
776bb9fabc
commit
926454c0d8
3 changed files with 5 additions and 5 deletions
|
@ -136,7 +136,7 @@ hashindex_read(const char *path)
|
||||||
HashHeader header;
|
HashHeader header;
|
||||||
HashIndex *index = NULL;
|
HashIndex *index = NULL;
|
||||||
|
|
||||||
if((fd = fopen(path, "r")) == NULL) {
|
if((fd = fopen(path, "rb")) == NULL) {
|
||||||
EPRINTF_PATH(path, "fopen for reading failed");
|
EPRINTF_PATH(path, "fopen for reading failed");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -260,7 +260,7 @@ hashindex_write(HashIndex *index, const char *path)
|
||||||
};
|
};
|
||||||
int ret = 1;
|
int ret = 1;
|
||||||
|
|
||||||
if((fd = fopen(path, "w")) == NULL) {
|
if((fd = fopen(path, "wb")) == NULL) {
|
||||||
EPRINTF_PATH(path, "fopen for writing failed");
|
EPRINTF_PATH(path, "fopen for writing failed");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -93,7 +93,7 @@ class Cache:
|
||||||
with open(os.path.join(self.path, 'config'), 'w') as fd:
|
with open(os.path.join(self.path, 'config'), 'w') as fd:
|
||||||
config.write(fd)
|
config.write(fd)
|
||||||
ChunkIndex().write(os.path.join(self.path, 'chunks').encode('utf-8'))
|
ChunkIndex().write(os.path.join(self.path, 'chunks').encode('utf-8'))
|
||||||
with open(os.path.join(self.path, 'files'), 'w') as fd:
|
with open(os.path.join(self.path, 'files'), 'wb') as fd:
|
||||||
pass # empty file
|
pass # empty file
|
||||||
|
|
||||||
def destroy(self):
|
def destroy(self):
|
||||||
|
|
|
@ -400,9 +400,9 @@ class ArchiverTestCase(ArchiverTestCaseBase):
|
||||||
self.cmd('extract', '--dry-run', self.repository_location + '::test')
|
self.cmd('extract', '--dry-run', self.repository_location + '::test')
|
||||||
self.cmd('check', self.repository_location)
|
self.cmd('check', self.repository_location)
|
||||||
name = sorted(os.listdir(os.path.join(self.tmpdir, 'repository', 'data', '0')), reverse=True)[0]
|
name = sorted(os.listdir(os.path.join(self.tmpdir, 'repository', 'data', '0')), reverse=True)[0]
|
||||||
with open(os.path.join(self.tmpdir, 'repository', 'data', '0', name), 'r+') as fd:
|
with open(os.path.join(self.tmpdir, 'repository', 'data', '0', name), 'r+b') as fd:
|
||||||
fd.seek(100)
|
fd.seek(100)
|
||||||
fd.write('XXXX')
|
fd.write(b'XXXX')
|
||||||
self.cmd('check', self.repository_location, exit_code=1)
|
self.cmd('check', self.repository_location, exit_code=1)
|
||||||
|
|
||||||
def test_readonly_repository(self):
|
def test_readonly_repository(self):
|
||||||
|
|
Loading…
Add table
Reference in a new issue