def test_overwrite(self): fn, _ = gen_rand_file() n = content.create_file(fn) self.assertIn('id', n) n = content.overwrite_file(n['id'], fn) self.assertEqual(n['contentProperties']['version'], 2) trash.move_to_trash(n['id'])
def test_overwrite(self): fn = gen_rand_nm() open(fn, 'wb').close() n = content.upload_file(fn) self.assertIn('id', n) n = content.overwrite_file(n['id'], fn) self.assertEqual(n['contentProperties']['version'], 2) trash.move_to_trash(n['id']) os.remove(fn)
def overwrite(node_id, local_file) -> int: hasher = hashing.Hasher(local_file) try: r = content.overwrite_file(node_id, local_file) sync.insert_node(r) node = query.get_node(r['id']) return compare_hashes(node.md5, hasher.get_result(), local_file) except RequestError as e: hasher.stop() logger.error('Error overwriting file. Code: %s, msg: %s' % (e.status_code, e.msg)) return UL_DL_FAILED
def overwrite(node_id, local_file, dedup=False, pg_handler: progress.FileProgress=None) -> RetryRetVal: hasher = hashing.IncrementalHasher() try: r = content.overwrite_file(node_id, local_file, read_callbacks=[hasher.update, pg_handler.update], deduplication=dedup) sync.insert_node(r) node = query.get_node(r['id']) md5 = node.md5 return compare_hashes(md5, hasher.get_result(), local_file) except RequestError as e: logger.error('Error overwriting file. Code: %s, msg: %s' % (e.status_code, e.msg)) return UL_DL_FAILED