aws-sdk-ios icon indicating copy to clipboard operation
aws-sdk-ios copied to clipboard

Cache files left when AWSS3TransferUtilityMultiPartUploadTask canceled

Open SGA-ou-enhaku opened this issue 6 years ago • 4 comments

Describe the bug After [AWSS3TransferUtilityMultiPartUploadTask cancel] calling of big file such as 60MB, there are cache files left in /Library/Caches/S3TransferUtility. If [S3TransferUtility uploadFileUsingMultiPart:...] -> [task cancel] all the time, there would be bad for iPhone' storage.

To Reproduce Steps to reproduce the behavior:

  1. Call [S3TransferUtility uploadFileUsingMultiPart:...]
  2. Call [AWSS3TransferUtilityMultiPartUploadTask cancel]
  3. Go to (App)/Library/Caches/S3TransferUtility
  4. See the left cache files

Which AWS service(s) are affected? S3

Expected behavior A clear and concise description of what you expected to happen. Cache files should be deleted.

Environment(please complete the following information):

  • SDK Version: [2.9.8 and 2.8.2]
  • Dependency Manager: [Cocoapods]
  • Objective-C

Device Information (please complete the following information):

  • Device: [iPhoneXR, Simulator]
  • iOS Version: [iOS 12.1]

SGA-ou-enhaku avatar May 28 '19 02:05 SGA-ou-enhaku

Hi @SGA-ou-enhaku ,

Thanks for bringing this to our attention. This would be an agreeable improvement to the current behavior. We will look into prioritizing this item. In the meantime, we are open to pull requests if you are interested.

minbi avatar May 28 '19 20:05 minbi

I'm also having this. Please how could we remove the cache?

pablogeek avatar Jun 12 '19 23:06 pablogeek

this code solved my issue, I run this everytime something is correctly uploaded

    func cleanCache(){
        if let url = FileManager.default.urls(for: .cachesDirectory, in: .userDomainMask).first {
            let urls = try?  FileManager.default.contentsOfDirectory(at: url, includingPropertiesForKeys: nil, options: .skipsSubdirectoryDescendants)
            urls?.filter { $0.lastPathComponent.contains("S3") }.forEach { try? FileManager.default.removeItem(at: $0) }
        }
    }

pablogeek avatar Jul 07 '19 15:07 pablogeek

yes,you can call suspend and it will pause,no remove cache

Guolanlan avatar Sep 28 '20 12:09 Guolanlan