aws-amplify / aws-sdk-ios

AWS SDK for iOS. For more information, see our web site:
https://aws-amplify.github.io/docs
Other
1.68k stars 879 forks source link

Cache files left when AWSS3TransferUtilityMultiPartUploadTask canceled #1576

Open SGA-ou-enhaku opened 5 years ago

SGA-ou-enhaku commented 5 years ago

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):

Device Information (please complete the following information):

minbi commented 5 years ago

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.

pablogeek commented 5 years ago

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

pablogeek commented 5 years ago

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) }
        }
    }
Guolanlan commented 3 years ago

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