summaryrefslogtreecommitdiff
path: root/internal/regexes
diff options
context:
space:
mode:
authorLibravatar tobi <31960611+tsmethurst@users.noreply.github.com>2022-11-25 18:23:42 +0100
committerLibravatar GitHub <noreply@github.com>2022-11-25 17:23:42 +0000
commit13e9abd02a1f4003c7be922a22e8f1d095a55d61 (patch)
treeccc7b7bbb0d040dc1db84d581849a0e443f91698 /internal/regexes
parent[bugfix] Change emailVerified to true for admin account create (#1140) (diff)
downloadgotosocial-13e9abd02a1f4003c7be922a22e8f1d095a55d61.tar.xz
[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
Diffstat (limited to 'internal/regexes')
-rw-r--r--internal/regexes/regexes.go7
1 files changed, 7 insertions, 0 deletions
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.