diff --git a/swh/loader/svn/ra.py b/swh/loader/svn/ra.py --- a/swh/loader/svn/ra.py +++ b/swh/loader/svn/ra.py @@ -121,6 +121,8 @@ (as per svn) and the link target. """ + if os.path.islink(fullpath): + return False, b"" with open(fullpath, "rb") as f: filetype, src = read_svn_link(f.read()) return filetype == b"link", src @@ -276,7 +278,7 @@ is_link, src = is_file_an_svnlink_p(self.fullpath) if is_link: self.__make_symlink(src) - else: # not a real link ... + elif not os.path.isdir(self.fullpath): # not a real link ... # when a file with the svn:special property set is not a svn link, # the svn export operation might extract a truncated version of it # if it is a binary file, so ensure to produce the same file as the diff --git a/swh/loader/svn/tests/test_loader.py b/swh/loader/svn/tests/test_loader.py --- a/swh/loader/svn/tests/test_loader.py +++ b/swh/loader/svn/tests/test_loader.py @@ -1836,3 +1836,53 @@ type="svn", snapshot=GOURMET_SNAPSHOT.id, ) + + +def test_loader_svn_add_property_on_directory_link(swh_storage, tmp_path): + # create a repository + repo_path = os.path.join(tmp_path, "tmprepo") + repos.create(repo_path) + repo_url = f"file://{repo_path}" + + # first commit + add_commit( + repo_url, + "Add an executable file in a directory and a svn link to the directory.", + [ + CommitChange( + change_type=CommitChangeType.AddOrUpdate, + path="code/hello-world", + properties={"svn:executable": "*"}, + data=b"#!/bin/bash\necho Hello World !", + ), + CommitChange( + change_type=CommitChangeType.AddOrUpdate, + path="hello", + properties={"svn:special": "*"}, + data=b"link code", + ), + ], + ) + + # second commit + add_commit( + repo_url, + "Set svn:eol-style property on link", + [ + CommitChange( + change_type=CommitChangeType.AddOrUpdate, + path="hello", + properties={"svn:eol-style": "native"}, + ), + ], + ) + + # instantiate a svn loader checking after each processed revision that + # the repository filesystem it reconstructed does not differ from a subversion + # export of that revision + loader = SvnLoader(swh_storage, repo_url, temp_directory=tmp_path, check_revision=1) + + assert loader.load() == {"status": "eventful"} + assert_last_visit_matches( + loader.storage, repo_url, status="full", type="svn", + )