summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAngelos Evripiotis <jevripiotis@bloomberg.net>2019-06-11 14:37:43 +0100
committerbst-marge-bot <marge-bot@buildstream.build>2019-06-18 09:45:00 +0000
commite55a89bffad51955c6c245eac5df98d025b586b9 (patch)
tree01758173bcbc6547ecfff79d41aa3ae7f59d0f88 /src
parentfe9a1dc1995f0da93c65ad9eb77d0e18061b3735 (diff)
downloadbuildstream-e55a89bffad51955c6c245eac5df98d025b586b9.tar.gz
_filebaseddirectory: match methods to base class
Update import_single_file and export_to_tar to match the Directory base class. This ensures that FileBasedDirectory is a fully substitutable Directory. By making the signatures deliberately match, we can use PyLint to ensure the signatures don't accidentally differ.
Diffstat (limited to 'src')
-rw-r--r--src/buildstream/storage/_filebaseddirectory.py20
1 files changed, 10 insertions, 10 deletions
diff --git a/src/buildstream/storage/_filebaseddirectory.py b/src/buildstream/storage/_filebaseddirectory.py
index 90911da86..233b56a09 100644
--- a/src/buildstream/storage/_filebaseddirectory.py
+++ b/src/buildstream/storage/_filebaseddirectory.py
@@ -112,13 +112,13 @@ class FileBasedDirectory(Directory):
os.utime(os.path.join(self.external_directory, f), times=(cur_time, cur_time))
return import_result
- def import_single_file(self, srcpath):
- dstpath = os.path.join(self.external_directory, os.path.basename(srcpath))
+ def import_single_file(self, external_pathspec):
+ dstpath = os.path.join(self.external_directory, os.path.basename(external_pathspec))
result = FileListResult()
if os.path.exists(dstpath):
result.ignored.append(dstpath)
else:
- shutil.copyfile(srcpath, dstpath, follow_symlinks=False)
+ shutil.copyfile(external_pathspec, dstpath, follow_symlinks=False)
return result
def _mark_changed(self):
@@ -153,23 +153,23 @@ class FileBasedDirectory(Directory):
# First, it sorts the results of os.listdir() to ensure the ordering of
# the files in the archive is the same. Second, it sets a fixed
# timestamp for each entry. See also https://bugs.python.org/issue24465.
- def export_to_tar(self, tf, dir_arcname, mtime=_magic_timestamp):
+ def export_to_tar(self, tarfile, destination_dir, mtime=_magic_timestamp):
# We need directories here, including non-empty ones,
# so list_relative_paths is not used.
for filename in sorted(os.listdir(self.external_directory)):
source_name = os.path.join(self.external_directory, filename)
- arcname = os.path.join(dir_arcname, filename)
- tarinfo = tf.gettarinfo(source_name, arcname)
+ arcname = os.path.join(destination_dir, filename)
+ tarinfo = tarfile.gettarinfo(source_name, arcname)
tarinfo.mtime = mtime
if tarinfo.isreg():
with open(source_name, "rb") as f:
- tf.addfile(tarinfo, f)
+ tarfile.addfile(tarinfo, f)
elif tarinfo.isdir():
- tf.addfile(tarinfo)
- self.descend(*filename.split(os.path.sep)).export_to_tar(tf, arcname, mtime)
+ tarfile.addfile(tarinfo)
+ self.descend(*filename.split(os.path.sep)).export_to_tar(tarfile, arcname, mtime)
else:
- tf.addfile(tarinfo)
+ tarfile.addfile(tarinfo)
def is_empty(self):
it = os.scandir(self.external_directory)