pub async fn new_volume(
        &self,
        volume_name: &str,
        crypt: Arc<dyn Crypt>,
    ) -> Result<Arc<ObjectStore>, Error> {
        let root_store = self.filesystem.root_store();
        let store;
        let store_handle;
        let mut transaction =
            self.filesystem.clone().new_transaction(&[], Options::default()).await?;

        store_handle = ObjectStore::create_object(
            &root_store,
            &mut transaction,
            HandleOptions::default(),
            None,
        )
        .await?;

        store = ObjectStore::new_encrypted(root_store, store_handle, crypt).await?;
        store.set_trace(self.filesystem.trace());

        let object_id = store.get_next_object_id();

        // TODO(csuter): Creating the store here writes the store-info later, so we should set the
        // graveyard object ID before that happens.  Creating the graveyard also queues a mutation
        // to set the graveyard object ID, which is unnececessary.  We should consider changing this
        // so that the graveyard and root directory are created when the store is created.
        store.set_graveyard_directory_object_id(object_id);

        Graveyard::create(&mut transaction, &store);

        // We must register the store here because create will add mutations for the store.
        self.filesystem.object_manager().add_store(store.clone());

        // If the transaction fails, we must unregister the store.
        struct CleanUp<'a>(&'a ObjectStore);
        impl Drop for CleanUp<'_> {
            fn drop(&mut self) {
                self.0.filesystem().object_manager().forget_store(self.0.store_object_id());
            }
        }
        let clean_up = CleanUp(&store);

        // Actually create the store in the transaction.
        store.create(&mut transaction).await?;

        self.volume_directory()
            .add_child_volume(&mut transaction, volume_name, store.store_object_id())
            .await?;
        transaction.commit().await?;

        std::mem::forget(clean_up);

        Ok(store)
    }
/// Creates a new volume.  This is not thread-safe.
Creates a new volume.  This is not thread-safe.
Creates a new volume . This is not thread - safe .
pub async fn new_volume(
        &self,
        volume_name: &str,
        crypt: Arc<dyn Crypt>,
    ) -> Result<Arc<ObjectStore>, Error> {
        let root_store = self.filesystem.root_store();
        let store;
        let store_handle;
        let mut transaction =
            self.filesystem.clone().new_transaction(&[], Options::default()).await?;
        store_handle = ObjectStore::create_object(
            &root_store,
            &mut transaction,
            HandleOptions::default(),
            None,
        )
        .await?;
        store = ObjectStore::new_encrypted(root_store, store_handle, crypt).await?;
        store.set_trace(self.filesystem.trace());
        let object_id = store.get_next_object_id();
        // TODO(csuter): Creating the store here writes the store-info later, so we should set the
        // graveyard object ID before that happens.  Creating the graveyard also queues a mutation
        // to set the graveyard object ID, which is unnececessary.  We should consider changing this
        // so that the graveyard and root directory are created when the store is created.
        store.set_graveyard_directory_object_id(object_id);
        Graveyard::create(&mut transaction, &store);
        // We must register the store here because create will add mutations for the store.
        self.filesystem.object_manager().add_store(store.clone());
        // If the transaction fails, we must unregister the store.
        struct CleanUp<'a>(&'a ObjectStore);
        impl Drop for CleanUp<'_> {
            fn drop(&mut self) {
                self.0.filesystem().object_manager().forget_store(self.0.store_object_id());
            }
        }
        let clean_up = CleanUp(&store);
        // Actually create the store in the transaction.
        store.create(&mut transaction).await?;
        self.volume_directory()
            .add_child_volume(&mut transaction, volume_name, store.store_object_id())
            .await?;
        transaction.commit().await?;
        std::mem::forget(clean_up);
        Ok(store)
    }
pub async fn new_volume ( & self , volume_name : & str , crypt : Arc < dyn Crypt > , ) -> Result < Arc < ObjectStore > , Error > { let root_store = self . filesystem . root_store ( ) ; let store ; let store_handle ; let mut transaction = self . filesystem . clone ( ) . new_transaction ( & [ ] , Options :: default ( ) ) . await ? ; store_handle = ObjectStore :: create_object ( & root_store , & mut transaction , HandleOptions :: default ( ) , None , ) . await ? ; store = ObjectStore :: new_encrypted ( root_store , store_handle , crypt ) . await ? ; store . set_trace ( self . filesystem . trace ( ) ) ; let object_id = store . get_next_object_id ( ) ; // TODO(csuter): Creating the store here writes the store-info later, so we should set the // graveyard object ID before that happens.  Creating the graveyard also queues a mutation // to set the graveyard object ID, which is unnececessary.  We should consider changing this // so that the graveyard and root directory are created when the store is created. store . set_graveyard_directory_object_id ( object_id ) ; Graveyard :: create ( & mut transaction , & store ) ; // We must register the store here because create will add mutations for the store. self . filesystem . object_manager ( ) . add_store ( store . clone ( ) ) ; // If the transaction fails, we must unregister the store. struct CleanUp < ' a > ( & ' a ObjectStore ) ; impl Drop for CleanUp < ' _ > { fn drop ( & mut self ) { self . 0 . filesystem ( ) . object_manager ( ) . forget_store ( self . 0 . store_object_id ( ) ) ; } } let clean_up = CleanUp ( & store ) ; // Actually create the store in the transaction. store . create ( & mut transaction ) . await ? ; self . volume_directory ( ) . add_child_volume ( & mut transaction , volume_name , store . store_object_id ( ) ) . await ? ; transaction . commit ( ) . await ? ; std :: mem :: forget ( clean_up ) ; Ok ( store ) }
Creates a new volume.
Creates a new volume .
&self
volume_name
&str
crypt
Arc<dyn Crypt>
&self
volume_name
&str
crypt
Arc<dyn Crypt>