def make_identical(self) -> None: meta = Meta("FOO") self.repo.fs.meta_update(meta) fns = [] for loop in range(4): meta_new = meta.copy() data = self.repo.fs.file_read(meta.filename) meta_new.filename = "FOO_%03d" % loop fns.append(meta_new.filename) self.repo.fs.file_create(meta_new, data) self.repo.main("add", *fns) self.repo.main("commit")
def test_overwrite_identical( self ): meta = Meta( "FOO" ) self.repo.fs.meta_update(meta) for loop in range(4): meta_new = meta.copy() data = self.repo.fs.file_read( meta.filename ) meta_new.filename = "dir%d/FOO" % loop self.other.fs.file_create( meta_new, data ) self.basic_test("dir1") self.repo.file_check( "dir1/1970-01/FOO", exists=True ) self.repo.file_check( "dir1/1970-01/FOO-000", exists=False )
def test_read_create(self) -> None: self.goto_test_dir() new_fn = join("NEW_DIR", "NEW_DIR2", "NEW_FILE") meta = Meta(new_fn) meta.modtime = 10**2 self.fs.file_create(meta, (bytes("FOO", "utf8"), bytes("BAR", "utf8"))) tfile_abs = join(self.test_dir, new_fn) self.tdir.file_check(tfile_abs, exists=True) content = self.fs.file_read(meta.filename) # Then try with valid meta self.fs.meta_update(meta) meta.filename = "NEW_FILE2" fid = self.fs.file_read(new_fn) self.fs.file_create(meta, fid)
def file_check(self, filename, exists, checksum=None): fn = Path(self.fs.make_absolute(filename)) self.check(exists, fn.exists()) if checksum != None: meta = Meta(filename) self.fs.meta_update(meta) self.check(meta.checksum, checksum)
def test_cancel_resumed(self) -> None: meta = Meta("NEW_FILE") content = "THIS WILL BE IN DISK" self.repo.file_make("NEW_FILE", content=content) self.repo.fs.meta_update(meta) self.remote_open() self.remote.file_set(meta, chunks(content)) self.close()
def test_set_untracked(self) -> None: self.remote_open() self.repo.file_make("NEW_FILE") meta = Meta("NEW_FILE") self.repo.fs.meta_update(meta) self.repo.file_make("NEW_FILE", content="INVALIDFOO" * 16) with self.assertRaises(SA_SYNC_Exception_SSH_Server_Error): self.remote.file_set(meta, chunks(bytes("FOO" * 16, "utf8"))) self.close()
def check_equal(self, other: 'RepoInDir'): fn_local = {x for x in self.fs.recursive_walk_files(".")} fn_remote = {x for x in self.fs.recursive_walk_files(".")} self.check(fn_local, fn_remote) self.open_db() other.open_db() # Sets are equal -> all files ok for fn in fn_local: meta_local = Meta(fn) meta_other = Meta(fn) self.fs.meta_update(meta_local) other.fs.meta_update(meta_other) self.check(meta_local.modtime, meta_other.modtime) self.check(meta_local.checksum, meta_other.checksum) self.check_databases(other) other.check_databases(self)
def file_copy(self, filename_source: str, filename_target: str) -> None: fid = self.fs.file_read(filename_source) meta = Meta(filename_target) self.fs.file_create(meta, fid)