Skip to content

Commit

Permalink
Merge branch 'release/v0.15.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
gee1k committed Dec 6, 2019
2 parents bcd5e92 + bc29db3 commit 4cabacf
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
11 changes: 6 additions & 5 deletions uPic/General/Managers/ConfigManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,7 @@ public class ConfigManager {

//MARK: 临时处理 folder、filename 的数据到新版的 saveKey 中。后续版本需要移除
private func _upgradeHostData() {
if Defaults.bool(forKey: "_upgradedHostData") {
return
}
var changed = false
let hostItems = self.getHostItems()
for host in hostItems {
if (host.data == nil || !host.data!.containsKey(key: "saveKeyPath")) {
Expand All @@ -56,6 +54,8 @@ public class ConfigManager {
continue
}

changed = true

var saveKeyPath = ""

if data.containsKey(key: "folder") {
Expand All @@ -75,8 +75,9 @@ public class ConfigManager {
host.data?.setValue(saveKeyPath, forKey: "saveKeyPath")
}

self.setHostItems(items: hostItems)
Defaults.set(true, forKey: "_upgradedHostData")
if changed {
self.setHostItems(items: hostItems)
}
}

public func removeAllUserDefaults() {
Expand Down
12 changes: 6 additions & 6 deletions uPic/Models/HostSaveKey.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,19 +49,19 @@ public enum HostSaveKey: String, CaseIterable, Codable {
case .dateFilename:
return "{year}-{mon}-{day}-{filename}{.suffix}"
case .datetimeFilename:
return "{year}{mon}{day}{hours}{minutes}{seconds}-{filename}{.suffix}"
return "{year}{mon}{day}{hour}{minute}{second}-{filename}{.suffix}"
case .secondFilename:
return "{since_seconds}-{filename}{.suffix}"
return "{since_second}-{filename}{.suffix}"
case .millisecondFilename:
return "{since_milliseconds}-{filename}{.suffix}"
return "{since_millisecond}-{filename}{.suffix}"
case .dateRandom:
return "{year}-{mon}-{day}-{random}{.suffix}"
case .datetimeRandom:
return "{year}{mon}{day}{hours}{minutes}{seconds}-{random}{.suffix}"
return "{year}{mon}{day}{hour}{minute}{second}-{random}{.suffix}"
case .secondRandom:
return "{since_seconds}-{random}{.suffix}"
return "{since_second}-{random}{.suffix}"
case .millisecondRandom:
return "{since_milliseconds}-{random}{.suffix}"
return "{since_millisecond}-{random}{.suffix}"
}
}

Expand Down

0 comments on commit 4cabacf

Please sign in to comment.