This is an automated email from the ASF dual-hosted git repository. juergbi pushed a commit to branch jbilleter/filebaseddirectory in repository https://gitbox.apache.org/repos/asf/buildstream.git
commit e5bed2953679f5df84080b85fa062649f5d0fc82 Author: Jürg Billeter <[email protected]> AuthorDate: Sat Oct 3 20:27:14 2026 +0200 _filebaseddirectory.py: Fix `import_single_file()` Use the same logic as in `__import_files_from_directory()` to correctly handle symlinks and populate `FileListResult`. --- src/buildstream/storage/_filebaseddirectory.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/buildstream/storage/_filebaseddirectory.py b/src/buildstream/storage/_filebaseddirectory.py index e33378206..14eaa7915 100644 --- a/src/buildstream/storage/_filebaseddirectory.py +++ b/src/buildstream/storage/_filebaseddirectory.py @@ -61,12 +61,17 @@ class FileBasedDirectory(Directory): return self.__open_directory(paths, create=create, follow_symlinks=follow_symlinks) def import_single_file(self, external_pathspec: str) -> FileListResult: - dstpath = os.path.join(self.__external_directory, os.path.basename(external_pathspec)) + basename = os.path.basename(external_pathspec) + dstpath = os.path.join(self.__external_directory, basename) result = FileListResult() - if os.path.exists(dstpath): - result.ignored.append(dstpath) - else: - shutil.copyfile(external_pathspec, dstpath, follow_symlinks=False) + if os.path.lexists(dstpath): + if not os.path.isdir(dstpath): + result.overwritten.append(basename) + if not utils.safe_remove(dstpath): + result.ignored.append(basename) + return result + shutil.copyfile(external_pathspec, dstpath, follow_symlinks=False) + result.files_written.append(basename) return result # Add a directory entry deterministically to a tar file
