ZDCDiskManager

@interface ZDCDiskManager : NSObject

The DiskManager simplifies the process of persisting & caching files to disk.

The DiskManager supports two different storage modes:

  • Persistent: Files stored in persistent mode won’t be deleted unless you ask the DiskManager to delete them, or the underlying node/user is deleted from the database.
  • Cache: File stored in cache mode are treated as a temporarily file. They are added to a storage pool managed by the DiskManager. And when the max size of the storage pool is exceeded, the DiskManager automatically starts deleting files. Further, the files are stored in an OS-designated Caches folder, and are available for deletion by the OS due to low-disk-space pressure.
  • Allows you to configure the max size of the storage pool for cached (non-persistent) nodeData files.

    The value is designated in bytes. The default value is 25 MiB (1024 * 1024 * 25).

    Note

    Any value you configure is persisted to disk, and thus remains set between app launches.

    The DiskManager supports two different storage modes:

    • Persistent: Files stored in persistent mode won’t be deleted unless you ask the DiskManager to delete them, or the underlying node/user is deleted from the database.
    • Cache: File stored in cache mode are treated as a temporarily file. They are added to a storage pool managed by the DiskManager. And when the max size of the storage pool is exceeded, the DiskManager automatically starts deleting files. Further, the files are stored in an OS-designated Caches folder, and are available for deletion by the OS due to low-disk-space pressure.

    Declaration

    Objective-C

    @property (assign, readwrite, atomic) uint64_t maxNodeDataCacheSize;

    Swift

    var maxNodeDataCacheSize: UInt64 { get set }
  • Allows you to configure the max size of the storage pool for cached (non-persistent) nodeThumbnail files.

    The value is designated in bytes. The default value is 5 MiB (1024 * 1024 * 5).

    Note

    Any value you configure is persisted to disk, and thus remains set between app launches.

    The DiskManager supports two different storage modes:

    • Persistent: Files stored in persistent mode won’t be deleted unless you ask the DiskManager to delete them, or the underlying node/user is deleted from the database.
    • Cache: File stored in cache mode are treated as a temporarily file. They are added to a storage pool managed by the DiskManager. And when the max size of the storage pool is exceeded, the DiskManager automatically starts deleting files. Further, the files are stored in an OS-designated Caches folder, and are available for deletion by the OS due to low-disk-space pressure.

    Declaration

    Objective-C

    @property (assign, readwrite, atomic) uint64_t maxNodeThumbnailsCacheSize;

    Swift

    var maxNodeThumbnailsCacheSize: UInt64 { get set }
  • Allows you to configure the max size of the storage pool for cached (non-persistent) userAvatar files.

    The value is designated in bytes. The default value is 5 MiB (1024 * 1024 * 5).

    Note

    Any value you configure is persisted to disk, and thus remains set between app launches.

    The DiskManager supports two different storage modes:

    • Persistent: Files stored in persistent mode won’t be deleted unless you ask the DiskManager to delete them, or the underlying node/user is deleted from the database.
    • Cache: File stored in cache mode are treated as a temporarily file. They are added to a storage pool managed by the DiskManager. And when the max size of the storage pool is exceeded, the DiskManager automatically starts deleting files. Further, the files are stored in an OS-designated Caches folder, and are available for deletion by the OS due to low-disk-space pressure.

    Declaration

    Objective-C

    @property (assign, readwrite, atomic) uint64_t maxUserAvatarsCacheSize;

    Swift

    var maxUserAvatarsCacheSize: UInt64 { get set }
  • Allows you to configure a default expiration interval for cached (non-persistent) nodeData files, after which time the DiskManager will automatically delete the cached file from disk.

    A positive value indicates the DiskManager should automatically delete cached nodeData files after the given internal. For example, if you specify an interval of 7 days, then the DiskManager will delete a cached nodeData file once its lastModified value exceeds 7 days old.

    A non-positive value (zero or negative value) indicates the DiskManager should NOT automatically delete cached nodeData files.

    Keep in mind:

    • This value only applies to cached (non-persistent) nodeData files. That is, imported nodeData files where the storePersistently flag was NOT set.

    • This default value can be overriden on a per-file basis, by explicitly setting a non-zero value for the [ZDCDiskImport expiration] property.

    The default value is zero.

    Note

    NSTimeInterval is designated in seconds.

    Declaration

    Objective-C

    @property (assign, readwrite, atomic)
        NSTimeInterval defaultNodeDataCacheExpiration;

    Swift

    var defaultNodeDataCacheExpiration: TimeInterval { get set }
  • Allows you to configure a default expiration interval for cached (non-persistent) nodeThumbnail files, after which time the DiskManager will automatically delete the cached file from disk.

    A positive value indicates the DiskManager should automatically delete cached nodeThumbnail files after the given internal. For example, if you specify an interval of 7 days, then the DiskManager will delete a cached nodeThumbnail file once its lastModified value exceeds 7 days old.

    A non-positive value (zero or negative value) indicates the DiskManager should NOT automatically delete cached nodeThumbnail files.

    Keep in mind:

    • This value only applies to cached (non-persistent) nodeThumbnail files. That is, imported nodeThumbnail files where the storePersistently flag was NOT set.

    • This default value can be overriden on a per-file basis, by explicitly setting a non-zero value for the [ZDCDiskImport expiration] property.

    The default value is zero.

    Note

    NSTimeInterval is designated in seconds.

    Declaration

    Objective-C

    @property (assign, readwrite, atomic)
        NSTimeInterval defaultNodeThumbnailCacheExpiration;

    Swift

    var defaultNodeThumbnailCacheExpiration: TimeInterval { get set }
  • Allows you to configure a default expiration interval for cached (non-persistent) userAvatar files, after which time the DiskManager will automatically delete the cached file from disk.

    A positive value indicates the DiskManager should automatically delete cached userAvatar files after the given internal. For example, if you specify an interval of 7 days, then the DiskManager will delete a cached userAvatar file once its lastModified value exceeds 7 days old.

    A non-positive value (zero or negative value) indicates the DiskManager should NOT automatically delete cached userAvatar files.

    Keep in mind:

    • This value only applies to non-persistent userAvatar files. That is, imported userAvatar files where the storePersistently flag was NOT set.

    • This default value can be overriden on a per-file basis, by explicitly setting a non-zero value for the [ZDCDiskImport expiration] property.

    The default value is 7 days.

    Note

    NSTimeInterval is designated in seconds.

    Declaration

    Objective-C

    @property (assign, readwrite, atomic)
        NSTimeInterval defaultUserAvatarCacheExpiration;

    Swift

    var defaultUserAvatarCacheExpiration: TimeInterval { get set }
  • This method is designed to take an import, migrate it to an encrypted format, and then store it in a directory that’s being managed by the DiskManager.

    For example, you might download a file using the ZDCDownloadManager, and then pass the resulting CryptoFile into this method.

    By utilizing the DiskManager, you can efficiently manage your app’s storage. This is because the DiskManager has the notion of persistent vs non-persistent (cached) files. Persistent files stick around until you manually delete them (or until the corresponding node is deleted). Non-persistent files, however, are part of a configurable storage pool. You can set limits on the size of the storage pool, and the DiskManager automatically handles deleting data when the pool gets too big. You can also set optional expiration intervals for imported files, and the DiskManager automatically handles deleting the files when they get too old.

    Note

    Non-persistent files may also be deleted by the OS due to low disk space.

    Declaration

    Objective-C

    - (nullable ZDCCryptoFile *)importNodeData:(nonnull ZDCDiskImport *)import
                                       forNode:(nonnull ZDCNode *)node
                                         error:(NSError *_Nullable *_Nullable)
                                                   outError;

    Swift

    func importNodeData(_ import: ZDCDiskImport, for node: ZDCNode) throws -> ZDCCryptoFile

    Parameters

    import

    The data can be imported to the DiskManager from multiple formats.

    node

    The corresponding node for the file.

    Return Value

    The CryptoFile will be MOVED from its current location to a new location. So the old fileURL will no longer exist upon completion of this method. A new CryptoFile is returned with an updated fileURL property.

  • Returns whether or not the DiskManager currently has a data file for the given node.

    Warning

    This method only provides a snapshot of the current state, which may quickly change. Moments after you invoke this method, the cached file may be deleted (for various reasons). If you need to ensure the cached file sticks around for awhile, use a method that returns a ZDCCryptoFile (with its retainToken) for the file.

    Declaration

    Objective-C

    - (BOOL)hasNodeData:(nonnull NSString *)nodeID;

    Swift

    func hasNodeData(_ nodeID: String) -> Bool

    Parameters

    nodeID

    The node you’re interested in (nodeID == ZDCNode.uuid)

  • Exports the CryptoFile and associated info for the node’s data, if available on disk. The informaion is bundled in a ZDCDiskExport instance.

    If a CryptoFile is returned, it will have a non-nil -[ZDCCryptoFile retainToken] property. This prevents the DiskManager from deleting the file for as long as this retainToken isn’t deallocated.

    Keep in mind that while the retainToken will prevent the DiskManager from deleting the file, the OS is free to do what it pleases, and may decide to delete the file while the app is backgrounded.

    Declaration

    Objective-C

    - (nullable ZDCDiskExport *)nodeData:(nonnull ZDCNode *)node;

    Swift

    func nodeData(_ node: ZDCNode) -> ZDCDiskExport?

    Parameters

    node

    The node you’re interested in.

  • Returns a CryptoFile and associated info for the node’s data, if available on disk. The information is bundled in a ZDCDiskExport instance.

    If a CryptoFile is returned, it will have a non-nil -[ZDCCryptoFile retainToken] property. This prevents the DiskManager from deleting the file for as long as this retainToken isn’t deallocated.

    Keep in mind that although the retainToken will prevent the DiskManager from deleting the file, if the file is non-persistent (i.e. stored in an OS designated Caches folder), then the OS is free to do what it pleases, and may decide to delete the file while the app is backgrounded.

    Declaration

    Objective-C

    - (nullable ZDCDiskExport *)nodeData:(nonnull ZDCNode *)node
                         preferredFormat:(ZDCCryptoFileFormat)preferredFormat;

    Swift

    func nodeData(_ node: ZDCNode, preferredFormat: ZDCCryptoFileFormat) -> ZDCDiskExport?

    Parameters

    node

    The node you’re interested in.

    preferredFormat

    If you prefer a specific format, pass it here. If you don’t care, just pass ZDCCryptoFileFormat_Unknown.

  • Deletes data files for the given nodeID from disk.

    The files are deleted in a safe manner. That is, if any files are currently being retained (a retainToken is being held for them), then the files are simply marked for future deletion. And the file will be deleted as soon as its retainCount drops back to zero.

    Declaration

    Objective-C

    - (void)deleteNodeData:(nonnull NSString *)nodeID;

    Swift

    func deleteNodeData(_ nodeID: String)
  • Deletes data files for the given nodeIDs from disk.

    The files are deleted in a safe manner. That is, if any files are currently being retained (a retainToken is being held for them), then the files are simply marked for future deletion. And the file will be deleted as soon as its retainCount drops back to zero.

    Declaration

    Objective-C

    - (void)deleteNodeDataForNodeIDs:(nonnull NSArray<NSString *> *)nodeIDs;

    Swift

    func deleteNodeData(forNodeIDs nodeIDs: [String])
  • Migrates node data files between persistent & non-persistent.

    The files are migrated in a safe manner. That is, if any files are currently being retained (a retainToken/CryptoFile is being held for them), then file is instead copied, and the original file is marked for future deletion. And the file will be deleted as soon as its retainCount drops to zero.

    Declaration

    Objective-C

    - (void)makeNodeDataPersistent:(BOOL)persistent
                         forNodeID:(nonnull NSString *)nodeID;

    Swift

    func makeNodeDataPersistent(_ persistent: Bool, forNodeID nodeID: String)

    Parameters

    persistent

    If YES, then non-persistent data files will moved moved to a persistent location on disk. If NO, then persistent files will be moved to a non-persistent location on disk.

    nodeID

    The node for which you want to migrate files (nodeID == ZDCNode.uuid)

  • This method is designed to take a downloaded thumbnail and store it to disk into a directory that’s being managed by the DiskManager.

    For example, you might download a thumbnail using the ZDCDownloadManager, and then pass the resulting data into this method.

    By utilizing the DiskManager, you can efficiently manage your app’s storage. This is because the DiskManager has the notion of persistent vs non-persistent files. Persistent files stick around until you manually delete them (or until the corresponding node is deleted). Non-persistent files, however, are part of a cache with a configurable storage pool. You can set limits on the size of the storage pool, and the DiskManager automatically handles deleting data when the pool gets too big. You can also set optional expiration intervals for imported files, and the DiskManager automatically handles deleting the files when they get too old.

    Note

    Non-persistent files may also be deleted by the OS due to low disk space.

    Declaration

    Objective-C

    - (nullable ZDCCryptoFile *)importNodeThumbnail:(nonnull ZDCDiskImport *)import
                                            forNode:(nonnull ZDCNode *)node
                                              error:(NSError *_Nullable *_Nullable)
                                                        outError;

    Swift

    func importNodeThumbnail(_ import: ZDCDiskImport, for node: ZDCNode) throws -> ZDCCryptoFile

    Parameters

    import

    The data can be imported to the DiskManager from multiple formats.

    node

    The corresponding node for the file.

    Return Value

    The data will be saved to disk in an encrypted format. A new CryptoFile reference is returned that can be used to read the file.

  • Returns whether or not the DiskManager currently has a thumbnail for the given node.

    Warning

    This method only provides a snapshot of the current state, which may quickly change. Moments after you invoke this method, the cached file may be deleted (for various reasons). If you need to ensure the cached file sticks around for awhile, use a method that returns a ZDCCryptoFile (with its retainToken) for the file.

    Declaration

    Objective-C

    - (BOOL)hasNodeThumbnail:(nonnull NSString *)nodeID;

    Swift

    func hasNodeThumbnail(_ nodeID: String) -> Bool

    Parameters

    nodeID

    The node you’re interested in (nodeID == ZDCNode.uuid)

  • Returns a CryptoFile and associated info for the node’s thumbnail, if available on disk. The information is bundled in a ZDCDiskExport instance.

    If a CryptoFile is returned, it will have a non-nil -[ZDCCryptoFile retainToken] property. This prevents the DiskManager from deleting the file for as long as this retainToken isn’t deallocated.

    Keep in mind that although the retainToken will prevent the DiskManager from deleting the file, if the file is non-persistent (i.e. stored in an OS designated Caches folder), then the OS is free to do what it pleases, and may decide to delete the file while the app is backgrounded.

    Declaration

    Objective-C

    - (nullable ZDCDiskExport *)nodeThumbnail:(nonnull ZDCNode *)node;

    Swift

    func nodeThumbnail(_ node: ZDCNode) -> ZDCDiskExport?

    Parameters

    node

    The node you’re interested in.

  • Deletes thumbnail files for the given nodeID from disk.

    The files are deleted in a safe manner. That is, if any files are currently being retained (a retainToken is being held for them), then the files are simply marked for future deletion. And the file will be deleted as soon as its retainCount drops back to zero.

    Declaration

    Objective-C

    - (void)deleteNodeThumbnail:(nonnull NSString *)nodeID;

    Swift

    func deleteNodeThumbnail(_ nodeID: String)
  • Deletes thumbnail files for the given nodeID’s from disk.

    The files are deleted in a safe manner. That is, if any files are currently being retained (a retainToken is being held for them), then the files are simply marked for future deletion. And the file will be deleted as soon as its retainCount drops back to zero.

    Declaration

    Objective-C

    - (void)deleteNodeThumbnailsForNodeIDs:(nonnull NSArray<NSString *> *)nodeIDs;

    Swift

    func deleteNodeThumbnails(forNodeIDs nodeIDs: [String])
  • Migrates node thumbnail files between persistent & non-persistent.

    The files are migrated in a safe manner. That is, if any files are currently being retained (a retainToken/CryptoFile is being held for them), then file is instead copied, and the original file is marked for future deletion. And the file will be deleted as soon as its retainCount drops to zero.

    Declaration

    Objective-C

    - (void)makeNodeThumbnailPersistent:(BOOL)persistent
                              forNodeID:(nonnull NSString *)nodeID;

    Swift

    func makeNodeThumbnailPersistent(_ persistent: Bool, forNodeID nodeID: String)

    Parameters

    persistent

    If YES, then non-persistent data files will moved moved to a persistent location on disk. If NO, then persistent files will be moved to a non-persistent location on disk.

    nodeID

    The node for which you want to migrate files (nodeID == ZDCNode.uuid)

  • This method is designed to take a CryptoFile that’s stored in a temp location, and move it into a directory that’s being managed by the DiskManager.

    For example, you might download a file using the ZDCDownloadManager, and then pass the resulting CryptoFile into this method.

    By utilizing the DiskManager, you can efficiently manage your app’s storage. This is because the DiskManager has the notion of persistent vs non-persistent (cached) files. Persistent files stick around until you manually delete them (or until the corresponding node is deleted). Non-persistent files, however, are part of a configurable storage pool. You can set limits on the size of the storage pool, and the DiskManager automatically handles deleting data when the pool gets too big. You can also set optional expiration intervals for imported files, and the DiskManager automatically handles deleting the files when they get too old.

    Note

    Non-persistent files may also be deleted by the OS due to low disk space.

    Declaration

    Objective-C

    - (nullable ZDCCryptoFile *)importUserAvatar:(nonnull ZDCDiskImport *)import
                                         forUser:(nonnull ZDCUser *)user
                                         auth0ID:(nonnull NSString *)auth0ID
                                           error:(NSError *_Nullable *_Nullable)
                                                     outError;

    Swift

    func importUserAvatar(_ import: ZDCDiskImport, for user: ZDCUser, auth0ID: String) throws -> ZDCCryptoFile

    Parameters

    import

    The data can be imported to the DiskManager from multiple formats.

    user

    The corresponding user for the file.

    auth0ID

    The auth0ID that corresponds to the avatar that was downloaded.

  • Returns whether or not the DiskManager currently has any avatars for the given user.

    Warning

    This method only provides a snapshot of the current state, which may quickly change. Moments after you invoke this method, the cached file may be deleted (for various reasons). If you need to ensure the cached file sticks around for awhile, use a method that returns a ZDCCryptoFile (with its retainToken) for the file.

    Declaration

    Objective-C

    - (BOOL)hasUserAvatar:(nonnull NSString *)userID;

    Swift

    func hasUserAvatar(_ userID: String) -> Bool

    Parameters

    userID

    The user you’re interested in (userID == ZDCUser.uuid)

  • Returns whether or not the DiskManager currently has an avatar for the given {userID, auth0ID} tuple. If you pass a nil auth0ID, it returns whether there are ANY avatars for the user.

    Warning

    This method only provides a snapshot of the current state, which may quickly change. Moments after you invoke this method, the cached file may be deleted (for various reasons). If you need to ensure the cached file sticks around for awhile, use a method that returns a ZDCCryptoFile (with its retainToken) for the file.

    Declaration

    Objective-C

    - (BOOL)hasUserAvatar:(nonnull NSString *)userID
               forAuth0ID:(nullable NSString *)auth0ID;

    Swift

    func hasUserAvatar(_ userID: String, forAuth0ID auth0ID: String?) -> Bool

    Parameters

    userID

    The user you’re interested in (userID == ZDCUser.uuid)

    auth0ID

    If you’re interested in a particular social identity.

  • Returns a CryptoFile and associated info for the user avatar, if available on disk. The information is bundled in a ZDCDiskExport instance.

    If a CryptoFile is returned, it will have a non-nil -[ZDCCryptoFile retainToken] property. This prevents the DiskManager from deleting the file for as long as this retainToken isn’t deallocated.

    Keep in mind that although the retainToken will prevent the DiskManager from deleting the file, if the file is non-persistent (i.e. stored in an OS designated Caches folder), then the OS is free to do what it pleases, and may decide to delete the file while the app is backgrounded.

    Declaration

    Objective-C

    - (nullable ZDCDiskExport *)userAvatar:(nonnull ZDCUser *)user;

    Swift

    func userAvatar(_ user: ZDCUser) -> ZDCDiskExport?

    Parameters

    user

    The user you’re interested in.

  • Returns a CryptoFile and associated info for the user avatar, if available on disk. The information is bundled in a ZDCDiskExport instance.

    If a CryptoFile is returned, it will have a non-nil -[ZDCCryptoFile retainToken] property. This prevents the DiskManager from deleting the file for as long as this retainToken isn’t deallocated.

    Keep in mind that although the retainToken will prevent the DiskManager from deleting the file, if the file is non-persistent (i.e. stored in an OS designated Caches folder), then the OS is free to do what it pleases, and may decide to delete the file while the app is backgrounded.

    Declaration

    Objective-C

    - (nullable ZDCDiskExport *)userAvatar:(nonnull ZDCUser *)user
                                forAuth0ID:(nullable NSString *)auth0ID;

    Swift

    func userAvatar(_ user: ZDCUser, forAuth0ID auth0ID: String?) -> ZDCDiskExport?

    Parameters

    user

    The user you’re interested in.

    auth0ID

    If you’re interested in the avatar for a particular social identity.

  • Deletes all avatar files for the given userID from disk.

    Note

    The files are deleted in a safe manner. That is, if any files are currently being retained (a retainToken is being held for them), then the files are simply marked for future deletion. And the file will be deleted as soon as its retainCount drops back to zero.

    Declaration

    Objective-C

    - (void)deleteUserAvatar:(nonnull NSString *)userID;

    Swift

    func deleteUserAvatar(_ userID: String)

    Parameters

    userID

    The user you’re interested in (userID == ZDCUser.uuid)

  • Deletes avatar files for the given userID’s from disk.

    Note

    The files are deleted in a safe manner. That is, if any files are currently being retained (a retainToken is being held for them), then the files are simply marked for future deletion. And the file will be deleted as soon as its retainCount drops back to zero.

    Declaration

    Objective-C

    - (void)deleteUserAvatarsForUserIDs:(nonnull NSArray<NSString *> *)userIDs;

    Swift

    func deleteUserAvatars(forUserIDs userIDs: [String])
  • Deletes the avatar file(s) for the given {userID, auth0ID} tuple from disk.

    Note

    The files are deleted in a safe manner. That is, if any files are currently being retained (a retainToken is being held for them), then the files are simply marked for future deletion. And the file will be deleted as soon as its retainCount drops back to zero.

    Declaration

    Objective-C

    - (void)deleteUserAvatar:(nonnull NSString *)userID
                  forAuth0ID:(nonnull NSString *)auth0ID;

    Swift

    func deleteUserAvatar(_ userID: String, forAuth0ID auth0ID: String)

    Parameters

    userID

    The user you’re interested in (userID == ZDCUser.uuid)

    auth0ID

    If you’re interested in the avatar for a particular social identity.

  • Migrates user avatar files between persistent & non-persistent.

    The files are migrated in a safe manner. That is, if any files are currently being retained (a retainToken/CryptoFile is being held for them), then file is instead copied, and the original file is marked for future deletion. And the file will be deleted as soon as its retainCount drops to zero.

    Declaration

    Objective-C

    - (void)makeUserAvatarPersistent:(BOOL)persistent
                           forUserID:(nonnull NSString *)userID;

    Swift

    func makeUserAvatarPersistent(_ persistent: Bool, forUserID userID: String)

    Parameters

    persistent

    If YES, then non-persistent data files will moved moved to a persistent location on disk. If NO, then persistent files will be moved to a non-persistent location on disk.

    userID

    The user for which you want to migrate files (userID == ZDCUser.uuid)

  • Returns the total size (summation) of all nodeData files on disk (in directories being managed by the DiskManager).

    Note

    This method involves asking the OS filesystem for file sizes. It’s normally quite fast, however this does involve disk IO. So you may prefer to invoke this method on a background thread.

    Declaration

    Objective-C

    - (uint64_t)storageSizeForAllNodeData;

    Swift

    func storageSizeForAllNodeData() -> UInt64
  • Returns the total size (summation) of all persistent nodeData files on disk (in directories being managed by the DiskManager).

    Note

    This method involves asking the OS filesystem for file sizes. It’s normally quite fast, however this does involve disk IO. So you may prefer to invoke this method on a background thread.

    Declaration

    Objective-C

    - (uint64_t)storageSizeForPersistentNodeData;

    Swift

    func storageSizeForPersistentNodeData() -> UInt64
  • Returns the total size (summation) of all cached (non-persistent) nodeData files on disk (in directories being managed by the DiskManager).

    Note

    This method involves asking the OS filesystem for file sizes. It’s normally quite fast, however this does involve disk IO. So you may prefer to invoke this method on a background thread.

    Note

    The current size may temporarily exceed the configured max size if a file is queued for deletion, but is currently being used by the app. (e.g. A ZDCCryptoFile.retainToken is keeping the file from being immediately deleted.)

    Declaration

    Objective-C

    - (uint64_t)storageSizeForCachedNodeData;

    Swift

    func storageSizeForCachedNodeData() -> UInt64
  • Returns the total size (summation) of all nodeThumbnail files on disk (in directories being managed by the DiskManager).

    Note

    This method involves asking the OS filesystem for file sizes. It’s normally quite fast, however this does involve disk IO. So you may prefer to invoke this method on a background thread.

    Declaration

    Objective-C

    - (uint64_t)storageSizeForAllNodeThumbnails;

    Swift

    func storageSizeForAllNodeThumbnails() -> UInt64
  • Returns the total size (summation) of all persistent nodeThumbnail files on disk (in directories being managed by the DiskManager).

    Note

    This method involves asking the OS filesystem for file sizes. It’s normally quite fast, however this does involve disk IO. So you may prefer to invoke this method on a background thread.

    Declaration

    Objective-C

    - (uint64_t)storageSizeForPersistentNodeThumbnail;

    Swift

    func storageSizeForPersistentNodeThumbnail() -> UInt64
  • Returns the total size (summation) of all cached (non-persistent) nodeThumbnail files on disk (in directories being managed by the DiskManager).

    Note

    This method involves asking the OS filesystem for file sizes. It’s normally quite fast, however this does involve disk IO. So you may prefer to invoke this method on a background thread.

    Note

    The current size may temporarily exceed the configured max size if a file is queued for deletion, but is currently being used by the app. (e.g. A ZDCCryptoFile.retainToken is keeping the file from being immediately deleted.)

    Declaration

    Objective-C

    - (uint64_t)storageSizeForCachedNodeThumbnails;

    Swift

    func storageSizeForCachedNodeThumbnails() -> UInt64
  • Returns the total size (summation) of all userAvatar files on disk (in directories being managed by the DiskManager).

    Note

    This method involves asking the OS filesystem for file sizes. It’s normally quite fast, however this does involve disk IO. So you may prefer to invoke this method on a background thread.

    Declaration

    Objective-C

    - (uint64_t)storageSizeForAllUserAvatars;

    Swift

    func storageSizeForAllUserAvatars() -> UInt64
  • Returns the total size (summation) of all persistent userAvatar files on disk (in directories being managed by the DiskManager).

    Note

    This method involves asking the OS filesystem for file sizes. It’s normally quite fast, however this does involve disk IO. So you may prefer to invoke this method on a background thread.

    Declaration

    Objective-C

    - (uint64_t)storageSizeForPersistentUserAvatars;

    Swift

    func storageSizeForPersistentUserAvatars() -> UInt64
  • Returns the total size (summation) of all cached (non-persistent) userAvatar files on disk (in directories being managed by the DiskManager).

    Note

    This method involves asking the OS filesystem for file sizes. It’s normally quite fast, however this does involve disk IO. So you may prefer to invoke this method on a background thread.

    Note

    The current size may temporarily exceed the configured max size if a file is queued for deletion, but is currently being used by the app. (e.g. A ZDCCryptoFile.retainToken is keeping the file from being immediately deleted.)

    Declaration

    Objective-C

    - (uint64_t)storageSizeForCachedUserAvatars;

    Swift

    func storageSizeForCachedUserAvatars() -> UInt64
  • Deletes the given file from the filesystem, so long as it’s not being managed by the DiskManager.

    When you download files using the ZDCDownloadManager, you’re given the option of storing the downloaded file into the DiskManager automatically. When you choose to do so, then the returned file is managed by the DiskManager, and thus you shouldn’t delete it. But when you choose not to do so, then the returned file is sitting in a temp directory. And you’re encouraged to delete it when you’re done with it. Having two very different requirements is just asking for bugs. So instead, you can simply use this API every single time, which will always just do the right thing for you.

    Declaration

    Objective-C

    - (void)deleteFileIfUnmanaged:(nonnull NSURL *)fileURL;

    Swift

    func deleteFileIfUnmanaged(_ fileURL: URL)