From ba7e4448d1eb5e7db1cf2cb7c9d27581d677bfaa Mon Sep 17 00:00:00 2001 From: Timofey Solomko Date: Sat, 22 Jan 2022 13:38:02 +0300 Subject: [PATCH] [TAR] Simplify TarWriter.finalize This is possible since the write function already performs the synchronization the file handle. --- Sources/TAR/TarWriter.swift | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/Sources/TAR/TarWriter.swift b/Sources/TAR/TarWriter.swift index ed6ded1a..fa9ea9c5 100644 --- a/Sources/TAR/TarWriter.swift +++ b/Sources/TAR/TarWriter.swift @@ -73,20 +73,13 @@ public struct TarWriter { public func finalize() throws { // First, we append two 512-byte blocks consisting of zeros as an EOF marker. try write(Data(count: 1024)) - #if compiler(<5.2) - handle.synchronizeFile() - #else - if #available(macOS 10.15.4, iOS 13.4, watchOS 6.2, tvOS 13.4, *) { - try handle.synchronize() - } else { - handle.synchronizeFile() - } - #endif + // The synchronization is performed by the write(_:) function automatically. } private func write(_ data: Data) throws { #if compiler(<5.2) handle.write(data) + handle.synchronizeFile() #else if #available(macOS 10.15.4, iOS 13.4, watchOS 6.2, tvOS 13.4, *) { try handle.write(contentsOf: data)