Beispiel #1
0
        /// <summary>
        /// Delete all subfolders and items in a folder.
        /// </summary>
        /// <param name="folderID">the folder UUID</param>
        public void deleteFolderContents(UUID folderID)
        {
            try
            {
                using (ISimpleDB conn = _connFactory.GetConnection())
                {
                    using (ITransaction transaction = conn.BeginTransaction()) // Use a transaction to guarantee that the following it atomic - it'd be bad to have a partial delete of the tree!
                    {
                        deleteFolderContents(conn, folderID);

                        // Increment the version of the purged folder.
                        this.IncrementSpecifiedFolderVersion(conn, folderID);

                        transaction.Commit();
                    }
                }
            }
            catch (Exception e)
            {
                m_log.Error(e.ToString());
            }
        }
Beispiel #2
0
        /// <summary>
        /// Deletes an inventory folder
        /// </summary>
        /// <param name="folderId">Id of folder to delete</param>
        public void deleteInventoryFolder(InventoryFolderBase folder)
        {
            // Get a flattened list of all subfolders.
            List <InventoryFolderBase> subFolders = getFolderHierarchy(folder.ID);

            try
            {
                using (ISimpleDB conn = _connFactory.GetConnection())
                {
                    using (ITransaction transaction = conn.BeginTransaction()) // Use a transaction to guarantee that the following it atomic - it'd be bad to have a partial delete of the tree!
                    {
                        // Since the DB doesn't currently have foreign key constraints the order of delete ops doean't matter,
                        //  however it's better practice to remove the contents and then remove the folder itself.

                        // Delete all sub-folders
                        foreach (InventoryFolderBase f in subFolders)
                        {
                            deleteFolderContents(conn, f.ID);
                            deleteOneFolder(conn, f);
                        }

                        // Delete the actual row
                        deleteFolderContents(conn, folder.ID);
                        deleteOneFolder(conn, folder);

                        // Increment the version of the parent of the purged folder.
                        this.IncrementSpecifiedFolderVersion(conn, folder.ParentID);

                        transaction.Commit();
                    }
                }
            }
            catch (Exception e)
            {
                m_log.Error(e.ToString());
            }
        }