Folders and files are now deleted more comprehensively

This commit is contained in:
Igor Katson 2024-06-21 13:18:30 +01:00
parent 7147f16042
commit ace4bed0c6
No known key found for this signature in database
GPG key ID: B4EC22B66D61A3F5
13 changed files with 253 additions and 103 deletions

View file

@ -25,7 +25,7 @@ pub struct InMemoryExampleStorageFactory {}
impl StorageFactory for InMemoryExampleStorageFactory {
type Storage = InMemoryExampleStorage;
fn init_storage(
fn create(
&self,
info: &crate::torrent_state::ManagedTorrentInfo,
) -> anyhow::Result<InMemoryExampleStorage> {
@ -110,4 +110,12 @@ impl TorrentStorage for InMemoryExampleStorage {
file_infos: self.file_infos.clone(),
}))
}
fn init(&mut self, _meta: &crate::ManagedTorrentInfo) -> anyhow::Result<()> {
Ok(())
}
fn remove_directory_if_empty(&self, _path: &Path) -> anyhow::Result<()> {
Ok(())
}
}

View file

@ -18,7 +18,7 @@ pub struct MmapStorage {
impl StorageFactory for MmapStorageFactory {
type Storage = MmapStorage;
fn init_storage(&self, info: &ManagedTorrentInfo) -> anyhow::Result<Self::Storage> {
fn create(&self, info: &ManagedTorrentInfo) -> anyhow::Result<Self::Storage> {
Ok(MmapStorage {
mmap: RwLock::new(
MmapOptions::new()
@ -62,4 +62,12 @@ impl TorrentStorage for MmapStorage {
fn take(&self) -> anyhow::Result<Box<dyn TorrentStorage>> {
anyhow::bail!("not implemented")
}
fn init(&mut self, _meta: &ManagedTorrentInfo) -> anyhow::Result<()> {
Ok(())
}
fn remove_directory_if_empty(&self, _path: &std::path::Path) -> anyhow::Result<()> {
Ok(())
}
}