mirror of
https://github.com/hkalexling/Mango.git
synced 2025-08-02 10:55:30 -04:00
Merge branch 'dev' of https://github.com/hkalexling/Mango into dev
This commit is contained in:
commit
5779d225f6
@ -35,6 +35,23 @@ describe "compare_numerically" do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe "is_supported_file" do
|
||||||
|
it "returns true when the filename has a supported extension" do
|
||||||
|
filename = "manga.cbz"
|
||||||
|
is_supported_file(filename).should eq true
|
||||||
|
end
|
||||||
|
|
||||||
|
it "returns true when the filename does not have a supported extension" do
|
||||||
|
filename = "info.json"
|
||||||
|
is_supported_file(filename).should eq false
|
||||||
|
end
|
||||||
|
|
||||||
|
it "is case insensitive" do
|
||||||
|
filename = "manga.ZiP"
|
||||||
|
is_supported_file(filename).should eq true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
describe "chapter_sort" do
|
describe "chapter_sort" do
|
||||||
it "sorts correctly" do
|
it "sorts correctly" do
|
||||||
ary = ["Vol.1 Ch.01", "Vol.1 Ch.02", "Vol.2 Ch. 2.5", "Ch. 3", "Ch.04"]
|
ary = ["Vol.1 Ch.01", "Vol.1 Ch.02", "Vol.2 Ch. 2.5", "Ch. 3", "Ch.04"]
|
||||||
|
@ -36,7 +36,7 @@ class Title
|
|||||||
@title_ids << title.id
|
@title_ids << title.id
|
||||||
next
|
next
|
||||||
end
|
end
|
||||||
if [".zip", ".cbz", ".rar", ".cbr"].includes? File.extname path
|
if is_supported_file path
|
||||||
entry = Entry.new path, self
|
entry = Entry.new path, self
|
||||||
@entries << entry if entry.pages > 0 || entry.err_msg
|
@entries << entry if entry.pages > 0 || entry.err_msg
|
||||||
end
|
end
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
require "./util"
|
||||||
|
|
||||||
class File
|
class File
|
||||||
abstract struct Info
|
abstract struct Info
|
||||||
def inode
|
def inode
|
||||||
@ -17,7 +19,7 @@ class File
|
|||||||
# information as long as the above changes do not happen together with
|
# information as long as the above changes do not happen together with
|
||||||
# a file/folder rename, with no library scan in between.
|
# a file/folder rename, with no library scan in between.
|
||||||
def self.signature(filename) : UInt64
|
def self.signature(filename) : UInt64
|
||||||
if %w(.zip .rar .cbz .cbr).includes? File.extname filename
|
if is_supported_file filename
|
||||||
File.info(filename).inode
|
File.info(filename).inode
|
||||||
else
|
else
|
||||||
0u64
|
0u64
|
||||||
|
@ -2,6 +2,7 @@ IMGS_PER_PAGE = 5
|
|||||||
ENTRIES_IN_HOME_SECTIONS = 8
|
ENTRIES_IN_HOME_SECTIONS = 8
|
||||||
UPLOAD_URL_PREFIX = "/uploads"
|
UPLOAD_URL_PREFIX = "/uploads"
|
||||||
STATIC_DIRS = ["/css", "/js", "/img", "/favicon.ico"]
|
STATIC_DIRS = ["/css", "/js", "/img", "/favicon.ico"]
|
||||||
|
SUPPORTED_FILE_EXTNAMES = [".zip", ".cbz", ".rar", ".cbr"]
|
||||||
|
|
||||||
def random_str
|
def random_str
|
||||||
UUID.random.to_s.gsub "-", ""
|
UUID.random.to_s.gsub "-", ""
|
||||||
@ -31,6 +32,10 @@ def register_mime_types
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def is_supported_file(path)
|
||||||
|
SUPPORTED_FILE_EXTNAMES.includes? File.extname(path).downcase
|
||||||
|
end
|
||||||
|
|
||||||
struct Int
|
struct Int
|
||||||
def or(other : Int)
|
def or(other : Int)
|
||||||
if self == 0
|
if self == 0
|
||||||
|
Loading…
x
Reference in New Issue
Block a user