Mercurial > prosody-hg
comparison plugins/mod_http_file_share.lua @ 12007:dc72581e04ff
mod_http_file_share: Improve consistency of terminology in logging
Prefer 'prune' over 'delete' since it more strongly implies removal of
excess.
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Sat, 04 Dec 2021 15:03:26 +0100 |
| parents | 62a466e60515 |
| children | c01532ae6a3b |
comparison
equal
deleted
inserted
replaced
| 12006:62a466e60515 | 12007:dc72581e04ff |
|---|---|
| 484 for slot_id, slot_info in iter do | 484 for slot_id, slot_info in iter do |
| 485 num_expired = num_expired + 1; | 485 num_expired = num_expired + 1; |
| 486 upload_cache:set(slot_id, nil); | 486 upload_cache:set(slot_id, nil); |
| 487 local filename = get_filename(slot_id); | 487 local filename = get_filename(slot_id); |
| 488 local deleted, err, errno = os.remove(filename); | 488 local deleted, err, errno = os.remove(filename); |
| 489 if deleted or errno == ENOENT then | 489 if deleted or errno == ENOENT then -- removed successfully or it was already gone |
| 490 size_sum = size_sum + tonumber(slot_info.attr.size); | 490 size_sum = size_sum + tonumber(slot_info.attr.size); |
| 491 obsolete_uploads:push(slot_id); | 491 obsolete_uploads:push(slot_id); |
| 492 else | 492 else |
| 493 module:log("error", "Could not delete file %q: %s", filename, err); | 493 module:log("error", "Could not prune expired file %q: %s", filename, err); |
| 494 problem_deleting = true; | 494 problem_deleting = true; |
| 495 end | 495 end |
| 496 if num_expired % 100 == 0 then sleep(0.1); end | 496 if num_expired % 100 == 0 then sleep(0.1); end |
| 497 end | 497 end |
| 498 | 498 |
| 499 -- obsolete_uploads now contains slot ids for which the files have been | 499 -- obsolete_uploads now contains slot ids for which the files have been |
| 500 -- deleted and that needs to be cleared from the database | 500 -- removed and that needs to be cleared from the database |
| 501 | 501 |
| 502 local deletion_query = {["end"] = boundary_time}; | 502 local deletion_query = {["end"] = boundary_time}; |
| 503 if not problem_deleting then | 503 if not problem_deleting then |
| 504 module:log("info", "All (%d, %s) expired files successfully deleted", num_expired, B(size_sum)); | 504 module:log("info", "All (%d, %s) expired files successfully pruned", num_expired, B(size_sum)); |
| 505 -- we can delete based on time | 505 -- we can delete based on time |
| 506 else | 506 else |
| 507 module:log("warn", "%d out of %d expired files could not be deleted", num_expired-#obsolete_uploads, num_expired); | 507 module:log("warn", "%d out of %d expired files could not be pruned", num_expired-#obsolete_uploads, num_expired); |
| 508 -- we'll need to delete only those entries where the files were | 508 -- we'll need to delete only those entries where the files were |
| 509 -- successfully deleted, and then try again with the failed ones. | 509 -- successfully removed, and then try again with the failed ones. |
| 510 -- eventually the admin ought to notice and fix the permissions or | 510 -- eventually the admin ought to notice and fix the permissions or |
| 511 -- whatever the problem is. | 511 -- whatever the problem is. |
| 512 deletion_query = {ids = obsolete_uploads}; | 512 deletion_query = {ids = obsolete_uploads}; |
| 513 end | 513 end |
| 514 | 514 |
| 522 module:log("debug", "No metadata to remove"); | 522 module:log("debug", "No metadata to remove"); |
| 523 else | 523 else |
| 524 local removed, err = uploads:delete(nil, deletion_query); | 524 local removed, err = uploads:delete(nil, deletion_query); |
| 525 | 525 |
| 526 if removed == true or removed == num_expired or removed == #obsolete_uploads then | 526 if removed == true or removed == num_expired or removed == #obsolete_uploads then |
| 527 module:log("debug", "Removed all metadata for expired uploaded files"); | 527 module:log("debug", "Expired upload metadata pruned successfully"); |
| 528 else | 528 else |
| 529 module:log("error", "Problem removing metadata for deleted files: %s", err); | 529 module:log("error", "Problem removing metadata for expired files: %s", err); |
| 530 end | 530 end |
| 531 end | 531 end |
| 532 | 532 |
| 533 prune_done(); | 533 prune_done(); |
| 534 end); | 534 end); |
