fix: make sure volumeURLs are sorted, and are set correctly in metadata
This commit is contained in:
@@ -194,8 +194,10 @@ class ViewController: UIViewController, UIGestureRecognizerDelegate {
|
||||
loadLocalState()
|
||||
let volCovP = ProgressIndices(v: progress.v, c: 0, i: 0)
|
||||
let volumeDir = currentPath.appendingPathComponent("volumes")
|
||||
let archive = try! Archive(url: volumeDir.appendingPathComponent(metadata.volumes[progress.v].archive), accessMode: .read)
|
||||
let targetEntry = archive[metadata.volumes[volCovP.v].chapters[volCovP.c].images[volCovP.i].filename]!
|
||||
let archivePath = volumeDir.appendingPathComponent(metadata.volumes[volCovP.v].archive)
|
||||
let archive = try! Archive(url: archivePath, accessMode: .read)
|
||||
let filename = metadata.volumes[volCovP.v].chapters[volCovP.c].images[volCovP.i].filename!
|
||||
let targetEntry = archive[filename]!
|
||||
var extractedData = Data()
|
||||
_ = try archive.extract(targetEntry) { data in
|
||||
extractedData.append(data)
|
||||
@@ -205,7 +207,8 @@ class ViewController: UIViewController, UIGestureRecognizerDelegate {
|
||||
cover: UIImage(data: extractedData)!,
|
||||
metadata: metadata,
|
||||
path: dir
|
||||
))
|
||||
)
|
||||
)
|
||||
}
|
||||
} catch {
|
||||
print("Failed to read directories")
|
||||
@@ -289,6 +292,7 @@ class ViewController: UIViewController, UIGestureRecognizerDelegate {
|
||||
var volumes: [Offset] = []
|
||||
var currentChapters: [Offset] = []
|
||||
var currentImages: [Offset] = []
|
||||
var previousVolumeURL = ""
|
||||
|
||||
var titleValue: String = ""
|
||||
|
||||
@@ -304,12 +308,15 @@ class ViewController: UIViewController, UIGestureRecognizerDelegate {
|
||||
includingPropertiesForKeys: [.isRegularFileKey],
|
||||
options: [.skipsHiddenFiles]
|
||||
).filter { $0.pathExtension == "cbz" }
|
||||
.sorted { $0.lastPathComponent < $1.lastPathComponent }
|
||||
|
||||
if volumeURLs.isEmpty {
|
||||
print("found no volumes in volume dir: \(volumeDir)")
|
||||
return
|
||||
}
|
||||
|
||||
print("volumeURLs: \(volumeURLs)")
|
||||
|
||||
var filenames: [(String, String)] = []
|
||||
for volumeURL in volumeURLs {
|
||||
do {
|
||||
@@ -372,7 +379,6 @@ class ViewController: UIViewController, UIGestureRecognizerDelegate {
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
let regex = pattern!
|
||||
let titleRegex = titlePattern!
|
||||
|
||||
@@ -435,7 +441,7 @@ class ViewController: UIViewController, UIGestureRecognizerDelegate {
|
||||
currentChapters.append(chapterMetadata)
|
||||
|
||||
let volumeTitle = builder.create(string: "")
|
||||
let volumeURLOffset = builder.create(string: volumeURL)
|
||||
let volumeURLOffset = builder.create(string: previousVolumeURL)
|
||||
let chaptersOffset = builder.createVector(ofOffsets: currentChapters)
|
||||
let volumeMetadata = VolumeMetadata.createVolumeMetadata(
|
||||
&builder,
|
||||
@@ -507,6 +513,7 @@ class ViewController: UIViewController, UIGestureRecognizerDelegate {
|
||||
}
|
||||
currentVolume = volume
|
||||
currentChapter = chapter
|
||||
previousVolumeURL = volumeURL
|
||||
} else {
|
||||
print("no regex match on \(filename), returning")
|
||||
return
|
||||
@@ -1319,10 +1326,7 @@ class ViewController: UIViewController, UIGestureRecognizerDelegate {
|
||||
}
|
||||
|
||||
func setImages(path _: URL) {
|
||||
let scaling: UIView.ContentMode!
|
||||
if mode == .scroll {
|
||||
scaling = UIView.ContentMode.scaleAspectFill
|
||||
} else { scaling = UIView.ContentMode.scaleAspectFit }
|
||||
let scaling: UIView.ContentMode = mode == .scroll ? .scaleAspectFill : .scaleAspectFit
|
||||
imageLoader.loadImage(
|
||||
archiveURL: currentPath.appendingPathComponent("volumes").appendingPathComponent(metadata.volumes[progress.v].archive),
|
||||
filename: getImagePath(progress: progress),
|
||||
@@ -1330,8 +1334,8 @@ class ViewController: UIViewController, UIGestureRecognizerDelegate {
|
||||
screenSize: UIScreen.main.bounds.size
|
||||
) { [weak self] image in
|
||||
self?.imageView.image = image
|
||||
self?.updateInfo()
|
||||
}
|
||||
updateInfo()
|
||||
|
||||
var newProgress = progress
|
||||
for _ in 0 ..< preloadCount {
|
||||
|
||||
Reference in New Issue
Block a user