Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use attachment timestamp as modification date of exported attachment file #82

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions Sources/XCParseCore/XCResultToolCommand.swift
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,13 @@ open class XCResultToolCommand {
var id: String = ""
var outputPath: String = ""
var type: ExportType = ExportType.file
private let timestamp: Date?

public init(withXCResult xcresult: XCResult, id: String, outputPath: String, type: ExportType) {
self.id = id
self.outputPath = outputPath
self.type = type
self.timestamp = nil

var processArgs = xcresultToolArguments
processArgs.append(contentsOf: ["export",
Expand All @@ -89,6 +91,7 @@ open class XCResultToolCommand {
let attachmentOutputPath = URL.init(fileURLWithPath: outputPath).appendingPathComponent(filename)
self.outputPath = attachmentOutputPath.path
}
self.timestamp = attachment.timestamp

var processArgs = xcresultToolArguments
processArgs.append(contentsOf: ["export",
Expand All @@ -100,6 +103,14 @@ open class XCResultToolCommand {
let process = TSCBasic.Process(arguments: processArgs)
super.init(withXCResult: xcresult, process: process)
}

public override func run() -> ProcessResult? {
let superResult = super.run()
if superResult == nil { return nil }
guard let timestamp = timestamp else { return superResult }
try? FileManager.default.setAttributes([.modificationDate: timestamp as Any], ofItemAtPath: outputPath)
abotkin-cpi marked this conversation as resolved.
Show resolved Hide resolved
return superResult
}
}

open class Get: XCResultToolCommand {
Expand Down