Skip to content

Commit 9d4adf4

Browse files
committed
Make Zip Builder temp dirs sortable and understandable with timestamp (#4919)
1 parent 6ffe651 commit 9d4adf4

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

ZipBuilder/Sources/ZipBuilder/FileManager+Utils.swift

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,18 @@ extension FileManager {
101101
}
102102
}
103103

104-
// Enable a single unique temporary workspace per execution.
105-
static let unique: String = UUID().uuidString
104+
/// Enable a single unique temporary workspace per execution.
105+
private static func timeStamp() -> String {
106+
if #available(OSX 10.12, *) {
107+
let formatter = ISO8601DateFormatter()
108+
formatter.formatOptions.insert(.withInternetDateTime)
109+
return formatter.string(from: Date())
110+
} else {
111+
return UUID().uuidString
112+
}
113+
}
114+
115+
static let unique: String = timeStamp()
106116

107117
/// Returns a deterministic path of a temporary directory for the given name. Note: This does
108118
/// *not* create the directory if it doesn't exist, merely generates the name for creation.

0 commit comments

Comments
 (0)