Esempio n. 1
0
def _make_diff_increment(new, mirror, incpref, inc_time):
    """Make incfile which is a diff new -> mirror"""
    compress = _is_compressed(mirror)
    if compress:
        diff = get_inc(incpref, b"diff.gz", inc_time)
    else:
        diff = get_inc(incpref, b"diff", inc_time)

    old_new_perms, old_mirror_perms = (None, None)

    if Globals.process_uid != 0:
        # Check for unreadable files
        if not new.readable():
            old_new_perms = new.getperms()
            new.chmod(0o400 | old_new_perms)
        if not mirror.readable():
            old_mirror_perms = mirror.getperms()
            mirror.chmod(0o400 | old_mirror_perms)

    Rdiff.write_delta(new, mirror, diff, compress)

    if old_new_perms:
        new.chmod(old_new_perms)
    if old_mirror_perms:
        mirror.chmod(old_mirror_perms)

    rpath.copy_attribs_inc(mirror, diff)
    return diff
Esempio n. 2
0
    def testWriteDeltaGzip(self):
        """Same as above but delta is written gzipped"""
        rplist = [self.basis, self.new, self.delta, self.output]
        MakeRandomFile(self.basis.path)
        MakeRandomFile(self.new.path)
        list(map(rpath.RPath.setdata, [self.basis, self.new]))
        self.assertTrue(self.basis.lstat() and self.new.lstat())
        delta_gz = rpath.RPath(self.delta.conn, self.delta.path + b".gz")
        if delta_gz.lstat():
            delta_gz.delete()

        Rdiff.write_delta(self.basis, self.new, delta_gz, 1)
        self.assertTrue(delta_gz.lstat())
        if os.name == "nt":
            # simulate gunzip using 7z on Windows
            os_system(
                "7z e -tgzip -bb0 -y -o%s %s" %
                (os.fsdecode(delta_gz.get_parent_rp()), os.fsdecode(delta_gz)))
            os.unlink(delta_gz.path)
        else:
            os_system(b"gunzip %s" % delta_gz.path)
        delta_gz.setdata()
        self.delta.setdata()
        Rdiff.patch_local(self.basis, self.delta, self.output)
        self.assertTrue(rpath.cmp(self.new, self.output))
        list(map(rpath.RPath.delete, rplist))
Esempio n. 3
0
    def testWriteDelta(self):
        """Test write delta feature of rdiff"""
        if self.delta.lstat(): self.delta.delete()
        rplist = [self.basis, self.new, self.delta, self.output]
        MakeRandomFile(self.basis.path)
        MakeRandomFile(self.new.path)
        list(map(rpath.RPath.setdata, [self.basis, self.new]))
        assert self.basis.lstat() and self.new.lstat()

        Rdiff.write_delta(self.basis, self.new, self.delta)
        assert self.delta.lstat()
        Rdiff.patch_local(self.basis, self.delta, self.output)
        assert rpath.cmp(self.new, self.output)
        list(map(rpath.RPath.delete, rplist))
Esempio n. 4
0
	def testWriteDelta(self):
		"""Test write delta feature of rdiff"""
		if self.delta.lstat(): self.delta.delete()
		rplist = [self.basis, self.new, self.delta, self.output]
		MakeRandomFile(self.basis.path)
		MakeRandomFile(self.new.path)
		map(rpath.RPath.setdata, [self.basis, self.new])
		assert self.basis.lstat() and self.new.lstat()

		Rdiff.write_delta(self.basis, self.new, self.delta)
		assert self.delta.lstat()
		Rdiff.patch_local(self.basis, self.delta, self.output)
		assert rpath.cmp(self.new, self.output)
		map(rpath.RPath.delete, rplist)		
Esempio n. 5
0
    def testWriteDeltaGzip(self):
        """Same as above but delta is written gzipped"""
        rplist = [self.basis, self.new, self.delta, self.output]
        MakeRandomFile(self.basis.path)
        MakeRandomFile(self.new.path)
        list(map(rpath.RPath.setdata, [self.basis, self.new]))
        assert self.basis.lstat() and self.new.lstat()
        delta_gz = rpath.RPath(self.delta.conn, self.delta.path + ".gz")
        if delta_gz.lstat(): delta_gz.delete()

        Rdiff.write_delta(self.basis, self.new, delta_gz, 1)
        assert delta_gz.lstat()
        os.system("gunzip %s" % delta_gz.path)
        delta_gz.setdata()
        self.delta.setdata()
        Rdiff.patch_local(self.basis, self.delta, self.output)
        assert rpath.cmp(self.new, self.output)
        list(map(rpath.RPath.delete, rplist))
Esempio n. 6
0
	def testWriteDeltaGzip(self):
		"""Same as above but delta is written gzipped"""
		rplist = [self.basis, self.new, self.delta, self.output]
		MakeRandomFile(self.basis.path)
		MakeRandomFile(self.new.path)
		map(rpath.RPath.setdata, [self.basis, self.new])
		assert self.basis.lstat() and self.new.lstat()
		delta_gz = rpath.RPath(self.delta.conn, self.delta.path + ".gz")
		if delta_gz.lstat(): delta_gz.delete()

		Rdiff.write_delta(self.basis, self.new, delta_gz, 1)
		assert delta_gz.lstat()
		os.system("gunzip " + delta_gz.path)
		delta_gz.setdata()
		self.delta.setdata()
		Rdiff.patch_local(self.basis, self.delta, self.output)
		assert rpath.cmp(self.new, self.output)
		map(rpath.RPath.delete, rplist)