diff --git a/borg/_hashindex.c b/borg/_hashindex.c index 591f5c9f6..e2589d0b8 100644 --- a/borg/_hashindex.c +++ b/borg/_hashindex.c @@ -136,7 +136,7 @@ hashindex_read(const char *path) HashHeader header; HashIndex *index = NULL; - if((fd = fopen(path, "r")) == NULL) { + if((fd = fopen(path, "rb")) == NULL) { EPRINTF_PATH(path, "fopen for reading failed"); return NULL; } @@ -260,7 +260,7 @@ hashindex_write(HashIndex *index, const char *path) }; int ret = 1; - if((fd = fopen(path, "w")) == NULL) { + if((fd = fopen(path, "wb")) == NULL) { EPRINTF_PATH(path, "fopen for writing failed"); return 0; } diff --git a/borg/cache.py b/borg/cache.py index 037a8e76b..573a7f5cc 100644 --- a/borg/cache.py +++ b/borg/cache.py @@ -93,7 +93,7 @@ class Cache: with open(os.path.join(self.path, 'config'), 'w') as fd: config.write(fd) 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 def destroy(self): diff --git a/borg/testsuite/archiver.py b/borg/testsuite/archiver.py index 11efefd3d..b35df2477 100644 --- a/borg/testsuite/archiver.py +++ b/borg/testsuite/archiver.py @@ -400,9 +400,9 @@ class ArchiverTestCase(ArchiverTestCaseBase): self.cmd('extract', '--dry-run', self.repository_location + '::test') self.cmd('check', self.repository_location) 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.write('XXXX') + fd.write(b'XXXX') self.cmd('check', self.repository_location, exit_code=1) def test_readonly_repository(self):