Skip to content

Commit

Permalink
Enable ptr file creation for remote filesystem
Browse files Browse the repository at this point in the history
When a Storage Service is configured to connect to a pipeline on a
remote server it cannot see the location of the package before it
is transferred over to the storage service. In its current
configuration Archivematica tries to create a pointer file based on
an AIP being a file, or not, before this happens. We implement a
change to query the remote location and create a test for isfile().
  • Loading branch information
ross-spencer committed Mar 27, 2019
1 parent d83d383 commit 3f21a96
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
7 changes: 6 additions & 1 deletion storage_service/locations/models/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,12 @@ def should_have_pointer_file(self, package_full_path=None,
self.current_path)
if not package_type:
package_type = self.package_type
isfile = os.path.isfile(package_full_path)
# The package hasn't been moved yet, test for it being a file on the
# originating Space.
try:
isfile = self.origin_location.space.isfile(package_full_path)
except NotImplementedError:
isfile = os.path.isfile(package_full_path)
isaip = package_type in (Package.AIP, Package.AIC)
ret = isfile and isaip
if not ret:
Expand Down
10 changes: 10 additions & 0 deletions storage_service/locations/models/pipeline_local.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,3 +136,13 @@ def move_from_storage_service(self, source_path, destination_path, package=None)

# Move file
return self.space.move_rsync(source_path, destination_path, assume_rsync_daemon=self.assume_rsync_daemon, rsync_password=self.rsync_password)

def isfile(self, path):
"""Verify that something is a file in this Space's context."""
LOGGER.info("Testing if isfile in pipeline file system: %s", path)
basename = os.path.basename(path)
if not basename:
return False
location_entries = self.space.browse(os.path.dirname(path))
return (basename in location_entries.get("entries", []) and
basename not in location_entries.get("directories", []))
11 changes: 11 additions & 0 deletions storage_service/locations/models/space.py
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,17 @@ def check_package_fixity(self, package):
{'protocol': self.get_access_protocol_display()}
)

def isfile(self, path):
"""Verify that something is a file in the context of a given space."""
child = self.get_child_space()
if hasattr(child, 'isfile'):
return child.isfile(path)
else:
raise NotImplementedError(
_('Space %(protocol)s does not implement isfile') %
{'protocol': self.get_access_protocol_display()}
)

# HELPER FUNCTIONS

def move_rsync(self, source, destination, try_mv_local=False, assume_rsync_daemon=False, rsync_password=None):
Expand Down

0 comments on commit 3f21a96

Please sign in to comment.