diff --git a/source/Podfile.lock b/source/Podfile.lock index 546051d..3c3ee46 100644 --- a/source/Podfile.lock +++ b/source/Podfile.lock @@ -7,7 +7,7 @@ DEPENDENCIES: - SwiftyJSON (~> 5.0) SPEC REPOS: - https://github.com/CocoaPods/Specs.git: + https://github.com/cocoapods/specs.git: - Alamofire - SwiftyJSON @@ -17,4 +17,4 @@ SPEC CHECKSUMS: PODFILE CHECKSUM: 1e14da6108c97041b7daef307aaa48a8f180f7a4 -COCOAPODS: 1.8.0 +COCOAPODS: 1.7.5 diff --git a/source/tinypng4mac.xcodeproj/project.pbxproj b/source/tinypng4mac.xcodeproj/project.pbxproj index 2489306..a0bbe07 100644 --- a/source/tinypng4mac.xcodeproj/project.pbxproj +++ b/source/tinypng4mac.xcodeproj/project.pbxproj @@ -455,10 +455,10 @@ ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = "$(inherited)"; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 10; + CURRENT_PROJECT_VERSION = 11; INFOPLIST_FILE = tinypng4mac/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; - MARKETING_VERSION = 1.0.3; + MARKETING_VERSION = 1.0.4; PRODUCT_BUNDLE_IDENTIFIER = com.kyleduo.tinypngmac; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_VERSION = 5.0; @@ -472,10 +472,10 @@ ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = "$(inherited)"; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 10; + CURRENT_PROJECT_VERSION = 11; INFOPLIST_FILE = tinypng4mac/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; - MARKETING_VERSION = 1.0.3; + MARKETING_VERSION = 1.0.4; PRODUCT_BUNDLE_IDENTIFIER = com.kyleduo.tinypngmac; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_VERSION = 5.0; diff --git a/source/tinypng4mac/MainViewController.swift b/source/tinypng4mac/MainViewController.swift index 31f4fc1..8d888eb 100644 --- a/source/tinypng4mac/MainViewController.swift +++ b/source/tinypng4mac/MainViewController.swift @@ -223,8 +223,13 @@ class MainViewController: NSViewController, NSOpenSavePanelDelegate, NSTableView print(file.filePath.path) print(file.filePath.relativePath) let attributes = try? manager.attributesOfItem(atPath: file.filePath.path) - let size = attributes![FileAttributeKey.size]! - let task = TPTaskInfo(file, originSize: (size as AnyObject).doubleValue!) + let size = (attributes![FileAttributeKey.size]! as AnyObject).doubleValue! + let permission = TPConfig.shouldReplace() ? attributes![FileAttributeKey.posixPermissions] as! NSNumber? : nil + let task = TPTaskInfo( + file, + originSize: size, + filePermission: permission + ) tasks.append(task) } TPClient.sharedClient.add(tasks) diff --git a/source/tinypng4mac/model/TPTaskInfo.swift b/source/tinypng4mac/model/TPTaskInfo.swift index 5b2ade4..57d8805 100644 --- a/source/tinypng4mac/model/TPTaskInfo.swift +++ b/source/tinypng4mac/model/TPTaskInfo.swift @@ -12,6 +12,7 @@ class TPTaskInfo: NSObject { var originFile: URL var outputFile: URL? var resultUrl: String + var filePermission: NSNumber var fileInfo: FileInfo var originSize: Double var status: TPTaskStatus @@ -22,7 +23,7 @@ class TPTaskInfo: NSObject { var errorMessage: String? var index: Int - init(_ fileInfo: FileInfo, originSize: Double) { + init(_ fileInfo: FileInfo, originSize: Double, filePermission: NSNumber?) { self.originFile = fileInfo.filePath self.fileInfo = fileInfo self.originSize = originSize @@ -37,6 +38,7 @@ class TPTaskInfo: NSObject { self.uuid = UUID().uuidString self.errorMessage = nil self.index = 0 + self.filePermission = filePermission != nil ? filePermission! : NSNumber(value: 0o644) } override var description: String { diff --git a/source/tinypng4mac/tpclient/TPClient.swift b/source/tinypng4mac/tpclient/TPClient.swift index 43e8056..55a2867 100644 --- a/source/tinypng4mac/tpclient/TPClient.swift +++ b/source/tinypng4mac/tpclient/TPClient.swift @@ -144,7 +144,7 @@ class TPClient { self.updateStatus(task, newStatus: .finish) debugPrint("finish: " + task.fileInfo.relativePath + " tasks: " + String(self.runningTasks)) do { - try FileManager.default.setAttributes([FileAttributeKey.posixPermissions: NSNumber(value: 0o644)], ofItemAtPath: task.fileInfo.filePath.path) + try FileManager.default.setAttributes([FileAttributeKey.posixPermissions: task.filePermission], ofItemAtPath: task.fileInfo.filePath.path) } catch { debugPrint("FileManager set posixPermissions error") }