ZDCDiskImport

@interface ZDCDiskImport : NSObject

Encapsulates the parameters used when importing a file into the DiskManager.

  • Creates an empty import, which acts as a nil placeholder.

    This is used when a node’s thumbnail is nil, or a user’s avatar is nil, and the intention is to cache this result to prevent unnecessary future HTTP requests.

    Declaration

    Objective-C

    - (nonnull instancetype)init;

    Swift

    init()
  • Creates an import with the given cleartext data. The import process will encrypt the given data, and then write it to disk.

    Declaration

    Objective-C

    - (nonnull instancetype)initWithCleartextData:(nonnull NSData *)cleartextData;

    Swift

    init(cleartextData: Data)
  • Creates an import with the given cleartext file. The import process will create an encrypted copy of the file.

    Declaration

    Objective-C

    - (nonnull instancetype)initWithCleartextFileURL:
        (nonnull NSURL *)cleartextFileURL;

    Swift

    init(cleartextFileURL: URL)
  • Creates an import with the given crypto file. The import process will move the crypto file into a folder managed by the DiskManager.

    Declaration

    Objective-C

    - (nonnull instancetype)initWithCryptoFile:(nonnull ZDCCryptoFile *)cryptoFile;

    Swift

    init(cryptoFile: ZDCCryptoFile)
  • The parameter passed during init

    Declaration

    Objective-C

    @property (readonly, strong, nonatomic, nullable) NSData *cleartextData;

    Swift

    var cleartextData: Data? { get }
  • The parameter passed during init

    Declaration

    Objective-C

    @property (readonly, strong, nonatomic, nullable) NSURL *cleartextFileURL;

    Swift

    var cleartextFileURL: URL? { get }
  • The parameter passed during init

    Declaration

    Objective-C

    @property (readonly, strong, nonatomic, nullable) ZDCCryptoFile *cryptoFile;

    Swift

    var cryptoFile: ZDCCryptoFile? { get }
  • True if the all the following are nil: cleartextData, cleartextFileURL, & cryptoFile

    Note

    Nil placeholders are allowed for nodeThumbnail & userAvatar, but NOT for nodeData.

    Declaration

    Objective-C

    @property (readonly, nonatomic) BOOL isNilPlaceholder;

    Swift

    var isNilPlaceholder: Bool { get }
  • If YES, the file is stored using persistent mode. Persistent mode is kinda like a store offline mode that you see in some apps. That is, it won’t be deleted by the OS. It will only be deleted if you manually delete it, or if the corresponding node/user is deleted from the database.

    If NO, the file is stored using cache mode. It becomes part of a storage pool, and the max size of the storage pool is configurable. You can also set an optional expiration interval for temporarily cached files.

    The default value is NO/false.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic) BOOL storePersistently;

    Swift

    var storePersistently: Bool { get set }
  • This value applies to files being imported with the storePersistently flag set to true. If this value is also true, then it instructs the DiskManager to automatically migrate the file from persistent to cache mode after all queued PUT operations for the node have completed.

    This is a typical setting to use when you’re creating a new node. You want to ensure the file won’t be deleted from disk before the system has pushed it up to the cloud. But after the node was been pushed to the cloud, then the file can be deleted & so should be migrated to the cache.

    The default value is NO/false.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic) BOOL migrateToCacheAfterUpload;

    Swift

    var migrateToCacheAfterUpload: Bool { get set }
  • If set to true, it instructs the DiskManager to automatically delete the file after all queued PUT operations for the node have completed.

    This flag can be applied regardless of the storePersistently flag.

    The default value is NO/false.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic) BOOL deleteAfterUpload;

    Swift

    var deleteAfterUpload: Bool { get set }
  • The DiskManager can store an associated eTag with every imported file. This allows you to determine which version of a file is cached

    The eTag value is stored to disk in an encrypted manner. In particular, it is encrypted & then stored via an xattr.

    Declaration

    Objective-C

    @property (readwrite, copy, nonatomic, nullable) NSString *eTag;

    Swift

    var eTag: String? { get set }
  • The DiskManager supports an optional expiration interval (for non-persistent files).

    There are 2 values that control this:

    • The default value, configured via the ZDCDiskManager. (i.e. defaultNodeDataCacheExpiration, defaultNodeThumbnailCacheExpiration & defaultUserAvatarCacheExpiration)

    • The value you set here to (optionally) override the default value.

    Here’s how it works:

    • If you leave this value set to zero, then the imported file will inherit the default value.
    • If you set this value to a POSITIVE value, then the imported file will use this value as its expiration, regardless of the default settings.
    • If you set this value to a NEGATIVE value, then the imported file will NOT expire, regardless of the default settings.

    The default value is zero (meaning the import will inherit the default settings).

    Note

    The DiskManager will not expire files while they are stored in persistent mode (storePersistently == true). However, the expiration value will be applied to the file. (It gets stored as an xattr.) And if the file is later migrated from persistent to cache mode, then the previously applied expiration will affect the file.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic) NSTimeInterval expiration;

    Swift

    var expiration: TimeInterval { get set }