tus / TUSKit

The tus client for iOS.
https://tus.io/
MIT License
214 stars 115 forks source link

Version 3.4.0 couldNotDeleteFile error #196

Closed AVDyadkovich closed 1 month ago

AVDyadkovich commented 1 month ago

For some reason I receive 3.4.0 version via SPM.

In that version, you have changed code in file class Files in method

func removeFileAndMetadata(_ metaData: UploadMetadata) throws {
        let filePath = metaData.filePath
        let fileName = filePath.lastPathComponent
        let metaDataPath = storageDirectory.appendingPathComponent(fileName).appendingPathExtension("plist")
        let uploadDataCachePath = storageDirectory.appendingPathComponent("\(metaData.id)uploadData")
        let metaDataCachePath = storageDirectory.appendingPathComponent("\(metaData.id)")

        try queue.sync {
            try FileManager.default.removeItem(at: metaDataPath)
            try FileManager.default.removeItem(at: metaDataCachePath)

            if FileManager.default.fileExists(atPath: uploadDataCachePath.path) {
                try FileManager.default.removeItem(at: uploadDataCachePath)
            }
#if os(iOS)
            try FileManager.default.removeItem(at: filePath)
#endif
        }

When upload is finished, I receive an error couldNotDeleteFile

The reason for that is I do not have anything in uploadDataCachePath. On version 3.3.0 you have checking if uploadDataCachePath exist.

if FileManager.default.fileExists(atPath: metaDataCachePath.path) {
                try FileManager.default.removeItem(at: metaDataCachePath)
            }
donnywals commented 1 month ago

Hi @AVDyadkovich thanks for flagging this, looks like I had little too much faith in our test suite for this one..

I'll update tests and fix this issue with a new release later today.

Thanks again!