Skip to content

Commit

Permalink
Merge pull request #313 from DigitalSlideArchive/remove-delete-locks
Browse files Browse the repository at this point in the history
Add an option to remove stale deletelock files
  • Loading branch information
manthey committed Jan 15, 2024
2 parents 995169f + 251822d commit da3dc3e
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
29 changes: 29 additions & 0 deletions devops/dsa/provision.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,22 @@ def preprovision(opts):
subprocess.check_call(cmd, shell=True)


def clean_delete_locks():
from girder.constants import AssetstoreType
from girder.models.assetstore import Assetstore

for assetstore in Assetstore().find():
if assetstore['type'] != AssetstoreType.FILESYSTEM:
continue
rootpath = assetstore['root']
cmd = ['find', rootpath, '-name', '*.deleteLock', '-delete']
logger.info(f'Removing old delete locks: {cmd}')
try:
subprocess.check_call(cmd, shell=False)
except Exception:
logger.info(f'Failed trying to remove old delete locks: {cmd}')


def provision(opts): # noqa
"""
Provision the instance.
Expand Down Expand Up @@ -268,6 +284,10 @@ def provision(opts): # noqa
method = params.pop('method', 'createFilesystemAssetstore')
getattr(Assetstore(), method)(**params)

# Clean up old deleteLocks
if getattr(opts, 'clean-delete-locks', None):
clean_delete_locks()

# Make sure we have a demo collection and download some demo files
if getattr(opts, 'samples', None):
get_sample_data(
Expand Down Expand Up @@ -450,6 +470,8 @@ def merge_default_opts(opts):
'email': '[email protected]',
'public': True,
}
if getattr(opts, 'clean-delete-locks', None) is None:
setattr(opts, 'clean-delete-locks', True)
resources = opts.resources or []
resources.extend([{
'model': 'collection',
Expand Down Expand Up @@ -490,6 +512,13 @@ def __call__(self, parser, namespace, values, option_string=None):
parser.add_argument(
'--samples', '--data', '--sample-data',
action='store_true', help='Download sample data')
parser.add_argument(
'--clean-delete-locks', action='store_true',
help='Remove assetstore delete locks on start')
parser.add_argument(
'--no-clean-delete-locks', action='store_false',
dest='clean-delete-locks',
help='Do not remove assetstore delete locks on start')
parser.add_argument(
'--sample-collection', dest='sample-collection', default='Samples',
help='Sample data collection name')
Expand Down
1 change: 1 addition & 0 deletions devops/dsa/provision.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# This is a dictionary of command-line arguments for the provisioning script
force: False
samples: False
clean-delete-locks: True
sample-collection: Samples
sample-folder: Images
# Set use-defaults to False to skip default settings
Expand Down

0 comments on commit da3dc3e

Please sign in to comment.