From 13e9abd02a1f4003c7be922a22e8f1d095a55d61 Mon Sep 17 00:00:00 2001 From: tobi <31960611+tsmethurst@users.noreply.github.com> Date: Fri, 25 Nov 2022 18:23:42 +0100 Subject: [feature] Add `admin media prune orphaned` CLI command (#1146) * add FilePath regex * add `admin media prune orphaned` command * add prune orphaned function to media manager * don't mark flag as required * document admin media prune orphaned cmd * oh envparsing.sh you coy minx --- internal/regexes/regexes.go | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'internal/regexes/regexes.go') diff --git a/internal/regexes/regexes.go b/internal/regexes/regexes.go index c9286611e..657a79b91 100644 --- a/internal/regexes/regexes.go +++ b/internal/regexes/regexes.go @@ -140,6 +140,13 @@ var ( // BlockPath parses a path that validates and captures the username part and the ulid part // from eg /users/example_username/blocks/01F7XT5JZW1WMVSW1KADS8PVDH BlockPath = regexp.MustCompile(blockPath) + + filePath = fmt.Sprintf(`^(%s)/([a-z]+)/([a-z]+)/(%s)\.([a-z]+)$`, ulid, ulid) + // FilePath parses a file storage path of the form [ACCOUNT_ID]/[MEDIA_TYPE]/[MEDIA_SIZE]/[FILE_NAME] + // eg 01F8MH1H7YV1Z7D2C8K2730QBF/attachment/small/01F8MH8RMYQ6MSNY3JM2XT1CQ5.jpeg + // It captures the account id, media type, media size, file name, and file extension, eg + // `01F8MH1H7YV1Z7D2C8K2730QBF`, `attachment`, `small`, `01F8MH8RMYQ6MSNY3JM2XT1CQ5`, `jpeg`. + FilePath = regexp.MustCompile(filePath) ) // bufpool is a memory pool of byte buffers for use in our regex utility functions. -- cgit v1.2.3