Patent ID: 8549229

Claim:
A method for managing files with a storage device, the method comprising: in a host to which a storage device is operatively coupled, wherein the storage device includes a cache for storing one or more discardable files: identifying a file to be uploaded to an external location; determining whether sufficient free space exists in the cache to pre-stage the file for upload to the external location; determining that pre-staging the file for uploading to the external location requires more space than free space exists in the cache; associating discarding criteria with the file; determining whether one or more discardable files are stored in the cache that are associated with discarding criteria that is higher than that of the file to be pre-staged: removing one or more discardable files from the cache that are associated with discarding criteria that is higher than that of the file to be pre-staged to free UP space in the cache for the file to be pre-staged for uploading, starting with the discardable file associated with the highest discarding criteria and proceeding with the discardable file associated with the next highest discarding criteria, in sequence, wherein no more discardable files are removed from the cache than are needed to free up space in the cache for the file to be pre-staged; and storing the file in the cache upon determining that sufficient free space exists in the cache to pre-stage the file for upload to the external location, wherein pre-staging prepares a file for opportunistically uploading such file in accordance with an uploading policy.