Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Latest changes from ogdch-commands back into CKAN 2.10 compatible version #26

Merged
merged 9 commits into from
Sep 5, 2023
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,17 @@ It also comes with a dryrun option.
ckan -c /var/www/ckan/development.ini ogdch cleanup_resources
```

## Command to clean up the package extra table.
### Command to cleanup resource-files from the filestore.
When a resource gets deleted will be marked as deleted in the database and also its associated file in the CKAN-FileStore won't be deleted.
This command finds these orphaned files by checking whether their corresponding resource still exists.
It is meant to be run regularly by a cronjob.
It also comes with a dryrun option.

```bash
paster --plugin=ckanext-ogdchcommands ogdch cleanup_filestore -c /var/www/ckan/development.ini
```

## Command to cleanup the package extra table.
When a key is no longer needed in the package_extra table, since it is no longer part of the dataset,
then after the data have been migrated that old key can be removed from the package_extra table
and from the dependent table package_extra_revision.
Expand Down
4 changes: 2 additions & 2 deletions ckanext/ogdchcommands/logic.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,10 +233,10 @@ def ogdch_cleanup_filestore(context, data_dict):
filepaths = []
errors = []

for subdir, dirs, files in os.walk(storage_path):
for subdir, dirs, files in os.walk(resource_path):
for file in files:
fullpath = os.path.join(subdir, file)
relpath = os.path.relpath(fullpath, storage_path)
relpath = os.path.relpath(fullpath, resource_path)
resource_id = get_resource_id(relpath)

tk.check_access("resource_show", context, {"id": resource_id})
Expand Down
Loading