Summary: | Delete missing upload records | ||
---|---|---|---|
Product: | Koha | Reporter: | Marcel de Rooy <m.de.rooy> |
Component: | Architecture, internals, and plumbing | Assignee: | Marcel de Rooy <m.de.rooy> |
Status: | CLOSED FIXED | QA Contact: | Testopia <testopia> |
Severity: | enhancement | ||
Priority: | P5 - low | CC: | kyle, mirko |
Version: | Main | ||
Hardware: | All | ||
OS: | All | ||
Change sponsored?: | --- | Patch complexity: | Small patch |
Documentation contact: | Documentation submission: | ||
Text to go in the release notes: | Version(s) released in: | ||
Circulation function: | |||
Bug Depends on: | 17669 | ||
Bug Blocks: | |||
Attachments: |
Bug 18300: Delete missing upload records
Bug 18300: Delete missing upload records Bug 18300: Delete missing upload records Bug 18300: [QA Follow-up] Fix return value inconsistency Bug 18300: Delete missing upload records Bug 18300: [QA Follow-up] Fix return value inconsistency Bug 18300: Delete missing upload records Bug 18300: [QA Follow-up] Fix return value inconsistency |
Description
Marcel de Rooy
2017-03-19 15:50:00 UTC
Created attachment 61250 [details] [review] Bug 18300: Delete missing upload records If you deleted files from the upload directories manually, or you rebooted with files in the temporary upload folder, or for some other reason have records without a file, you may want to cleanup your records in the uploaded_files table. This patch adds the method delete_missing to Koha::UploadedFiles. It also supports a keep_record parameter to do a dry run (count the missing files first). Also, we add an option --uploads-missing to cleanup_database. If you add the flag 1 after this option, you will delete missing files. If you add the flag 0 or only use the option, you will count missing files. A subtest is added to Upload.t for delete_missing tests. Test plan: [1] Run t/db_dependent/Upload.t [2] Upload a file and delete the file manually. [3] Run cleanup_database.pl --uploads-missing It should report at least one missing file now. Check that the record has not been deleted. [4] Run cleanup_database.pl --uploads-missing 1 It should report that it removed at least one file. Check that the record is gone. Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> Created attachment 61470 [details] [review] Bug 18300: Delete missing upload records If you deleted files from the upload directories manually, or you rebooted with files in the temporary upload folder, or for some other reason have records without a file, you may want to cleanup your records in the uploaded_files table. This patch adds the method delete_missing to Koha::UploadedFiles. It also supports a keep_record parameter to do a dry run (count the missing files first). Also, we add an option --uploads-missing to cleanup_database. If you add the flag 1 after this option, you will delete missing files. If you add the flag 0 or only use the option, you will count missing files. A subtest is added to Upload.t for delete_missing tests. Test plan: [1] Run t/db_dependent/Upload.t [2] Upload a file and delete the file manually. [3] Run cleanup_database.pl --uploads-missing It should report at least one missing file now. Check that the record has not been deleted. [4] Run cleanup_database.pl --uploads-missing 1 It should report that it removed at least one file. Check that the record is gone. Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> Signed-off-by: Mirko Tietgen <mirko@abunchofthings.net> Created attachment 61778 [details] [review] Bug 18300: Delete missing upload records If you deleted files from the upload directories manually, or you rebooted with files in the temporary upload folder, or for some other reason have records without a file, you may want to cleanup your records in the uploaded_files table. This patch adds the method delete_missing to Koha::UploadedFiles. It also supports a keep_record parameter to do a dry run (count the missing files first). Also, we add an option --uploads-missing to cleanup_database. If you add the flag 1 after this option, you will delete missing files. If you add the flag 0 or only use the option, you will count missing files. A subtest is added to Upload.t for delete_missing tests. Test plan: [1] Run t/db_dependent/Upload.t [2] Upload a file and delete the file manually. [3] Run cleanup_database.pl --uploads-missing It should report at least one missing file now. Check that the record has not been deleted. [4] Run cleanup_database.pl --uploads-missing 1 It should report that it removed at least one file. Check that the record is gone. Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> Signed-off-by: Mirko Tietgen <mirko@abunchofthings.net> Rebased on top of changes in report 17669 (cleanup_database.pl) Temporarily blocked Created attachment 61810 [details] [review] Bug 18300: [QA Follow-up] Fix return value inconsistency As noted on bug report 17669, the return values of delete (both singular and plural), delete_missing and delete_temporary should be consistent. Created attachment 61821 [details] [review] Bug 18300: Delete missing upload records If you deleted files from the upload directories manually, or you rebooted with files in the temporary upload folder, or for some other reason have records without a file, you may want to cleanup your records in the uploaded_files table. This patch adds the method delete_missing to Koha::UploadedFiles. It also supports a keep_record parameter to do a dry run (count the missing files first). Also, we add an option --uploads-missing to cleanup_database. If you add the flag 1 after this option, you will delete missing files. If you add the flag 0 or only use the option, you will count missing files. A subtest is added to Upload.t for delete_missing tests. Test plan: [1] Run t/db_dependent/Upload.t [2] Upload a file and delete the file manually. [3] Run cleanup_database.pl --uploads-missing It should report at least one missing file now. Check that the record has not been deleted. [4] Run cleanup_database.pl --uploads-missing 1 It should report that it removed at least one file. Check that the record is gone. Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> Signed-off-by: Mirko Tietgen <mirko@abunchofthings.net> Created attachment 61822 [details] [review] Bug 18300: [QA Follow-up] Fix return value inconsistency As noted on bug report 17669, the return values of delete (both singular and plural), delete_missing and delete_temporary should be consistent. Removed the if-construction around full_path. We do not need it; in the very exceptional case that full_path would be empty, we should delete the record since the file is missing. Adjusted POD and unit tests accordingly. Test plan: Run t/db_dependent/Upload.t Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> Created attachment 62496 [details] [review] Bug 18300: Delete missing upload records If you deleted files from the upload directories manually, or you rebooted with files in the temporary upload folder, or for some other reason have records without a file, you may want to cleanup your records in the uploaded_files table. This patch adds the method delete_missing to Koha::UploadedFiles. It also supports a keep_record parameter to do a dry run (count the missing files first). Also, we add an option --uploads-missing to cleanup_database. If you add the flag 1 after this option, you will delete missing files. If you add the flag 0 or only use the option, you will count missing files. A subtest is added to Upload.t for delete_missing tests. Test plan: [1] Run t/db_dependent/Upload.t [2] Upload a file and delete the file manually. [3] Run cleanup_database.pl --uploads-missing It should report at least one missing file now. Check that the record has not been deleted. [4] Run cleanup_database.pl --uploads-missing 1 It should report that it removed at least one file. Check that the record is gone. Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> Signed-off-by: Mirko Tietgen <mirko@abunchofthings.net> Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> Created attachment 62497 [details] [review] Bug 18300: [QA Follow-up] Fix return value inconsistency As noted on bug report 17669, the return values of delete (both singular and plural), delete_missing and delete_temporary should be consistent. Removed the if-construction around full_path. We do not need it; in the very exceptional case that full_path would be empty, we should delete the record since the file is missing. Adjusted POD and unit tests accordingly. Test plan: Run t/db_dependent/Upload.t Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> Pushed to master for 17.05, thanks Marcel! This depends on bug 17669 which is not in 16.11.x. This won't get ported back to 16.11.x as it is an enhancement. |