Rename interesting files to supported files

This commit is contained in:
Alex Ling
2021-01-26 10:55:50 +00:00
parent 0ba2409c9a
commit def64d9f98
4 changed files with 16 additions and 19 deletions

View File

@@ -13,7 +13,7 @@ class File
# ensures that moving (unless to another device) and renaming the file
# preserves the signature, while copying or editing the file changes it.
def self.signature(filename) : UInt64
return 0u64 unless is_interesting_file filename
return 0u64 unless is_supported_file filename
info = File.info filename
signatures = [
info.inode,

View File

@@ -1,8 +1,8 @@
IMGS_PER_PAGE = 5
ENTRIES_IN_HOME_SECTIONS = 8
UPLOAD_URL_PREFIX = "/uploads"
STATIC_DIRS = ["/css", "/js", "/img", "/favicon.ico"]
INTERESTING_FILE_EXTNAMES = [".zip", ".cbz", ".rar", ".cbr"]
IMGS_PER_PAGE = 5
ENTRIES_IN_HOME_SECTIONS = 8
UPLOAD_URL_PREFIX = "/uploads"
STATIC_DIRS = ["/css", "/js", "/img", "/favicon.ico"]
SUPPORTED_FILE_EXTNAMES = [".zip", ".cbz", ".rar", ".cbr"]
def random_str
UUID.random.to_s.gsub "-", ""
@@ -32,8 +32,8 @@ def register_mime_types
end
end
def is_interesting_file(path)
INTERESTING_FILE_EXTNAMES.includes? (File.extname path).downcase
def is_supported_file(path)
SUPPORTED_FILE_EXTNAMES.includes? File.extname(path).downcase
end
struct Int