pub struct ManagedCacheDir { /* private fields */ }Expand description
Cache directory that will be created with appropriate permissions if it doesn’t exist, and - where configured - emptied at creation and when dropped.
When using a cache_key, the key is hashed and added as a subdirectory of mountpoint-cache.
Implementations§
Source§impl ManagedCacheDir
impl ManagedCacheDir
Sourcepub fn new_from_parent_with_cache_key(
parent_path: impl AsRef<Path>,
cache_key: Option<&OsStr>,
should_cleanup: bool,
) -> Result<Self, ManagedCacheDirError>
pub fn new_from_parent_with_cache_key( parent_path: impl AsRef<Path>, cache_key: Option<&OsStr>, should_cleanup: bool, ) -> Result<Self, ManagedCacheDirError>
Create a new directory inside the provided parent path.
If should_cleanup is true and <parent_path>/mountpoint-cache already exists,
it will be deleted before being recreated with the correct permissions.
If should_cleanup is false, the directory will only be created if it doesn’t exist.
Any existing directory will be used ‘as is’, and will not have its permissions updated.
By cleaning up the directory, we ensure caches are cleaned up where Mountpoint may have exited uncleanly and also ensure that the correct permissions are configured on the cache directory.
Sourcepub fn as_path_buf(&self) -> PathBuf
pub fn as_path_buf(&self) -> PathBuf
Create an owned copy of the managed path