예제 #1
0
 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'])
예제 #2
0
 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'])
예제 #3
0
 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)
예제 #4
0
파일: acd_cli.py 프로젝트: nabcos/acd_cli
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
예제 #5
0
파일: acd_cli.py 프로젝트: nabcos/acd_cli
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
예제 #6
0
파일: acd_cli.py 프로젝트: hansendc/acd_cli
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
예제 #7
0
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