##// END OF EJS Templates
archival: fsdecode paths before passing to tar or zip objects...
Augie Fackler -
r36724:bfe23afe default
parent child Browse files
Show More
@@ -21,6 +21,7 b' from . import ('
21 error,
21 error,
22 formatter,
22 formatter,
23 match as matchmod,
23 match as matchmod,
24 pycompat,
24 scmutil,
25 scmutil,
25 util,
26 util,
26 vfs as vfsmod,
27 vfs as vfsmod,
@@ -171,13 +172,14 b' class tarit(object):'
171 self.z = taropen('w|', fileobj=dest)
172 self.z = taropen('w|', fileobj=dest)
172
173
173 def addfile(self, name, mode, islink, data):
174 def addfile(self, name, mode, islink, data):
175 name = pycompat.fsdecode(name)
174 i = tarfile.TarInfo(name)
176 i = tarfile.TarInfo(name)
175 i.mtime = self.mtime
177 i.mtime = self.mtime
176 i.size = len(data)
178 i.size = len(data)
177 if islink:
179 if islink:
178 i.type = tarfile.SYMTYPE
180 i.type = tarfile.SYMTYPE
179 i.mode = 0o777
181 i.mode = 0o777
180 i.linkname = data
182 i.linkname = pycompat.fsdecode(data)
181 data = None
183 data = None
182 i.size = 0
184 i.size = 0
183 else:
185 else:
@@ -218,7 +220,7 b' class zipit(object):'
218 dest.tell()
220 dest.tell()
219 except (AttributeError, IOError):
221 except (AttributeError, IOError):
220 dest = tellable(dest)
222 dest = tellable(dest)
221 self.z = zipfile.ZipFile(dest, r'w',
223 self.z = zipfile.ZipFile(pycompat.fsdecode(dest), r'w',
222 compress and zipfile.ZIP_DEFLATED or
224 compress and zipfile.ZIP_DEFLATED or
223 zipfile.ZIP_STORED)
225 zipfile.ZIP_STORED)
224
226
@@ -232,7 +234,7 b' class zipit(object):'
232 self.date_time = time.gmtime(mtime)[:6]
234 self.date_time = time.gmtime(mtime)[:6]
233
235
234 def addfile(self, name, mode, islink, data):
236 def addfile(self, name, mode, islink, data):
235 i = zipfile.ZipInfo(name, self.date_time)
237 i = zipfile.ZipInfo(pycompat.fsdecode(name), self.date_time)
236 i.compress_type = self.z.compression
238 i.compress_type = self.z.compression
237 # unzip will not honor unix file modes unless file creator is
239 # unzip will not honor unix file modes unless file creator is
238 # set to unix (id 3).
240 # set to unix (id 3).
General Comments 0
You need to be logged in to leave comments. Login now