public void Empty()
        {
            _sessionLocator.For(typeof(CombinedFileRecord)).CreateQuery("DELETE FROM " + typeof(CombinedFileRecord).FullName).ExecuteUpdate();

            if (_storageProvider.FolderExists(RootPath))
            {
                _storageProvider.DeleteFolder(RootPath);
            }

            _combinatorEventHandler.CacheEmptied();
        }
Exemple #2
0
        //public void Delete(int hashCode)
        //{
        //    DeleteFiles(GetRecords(hashCode));

        //    TriggerCacheChangedSignal(hashCode);
        //}

        public void Empty()
        {
            var files = _fileRepository.Table.ToList();

            DeleteFiles(files);

            // These will throw an exception if a folder doesn't exist. Since currently there is no method
            // in IStorageProvider to check the existence of a file/folder (see: http://orchard.codeplex.com/discussions/275146)
            // this is the only way to deal with it.
            // We don't check if there were any files in a DB here, we try to delete even if there weren't. This adds robustness: with emptying the cache
            // everything can be reset, even if the user or a deploy process manipulated the DB or the file system.
            try
            {
                _storageProvider.DeleteFolder(_scriptsPath);
                Thread.Sleep(300); // This is to ensure we don't get an "access denied" when deleting the root folder
            }
            catch (Exception ex)
            {
                if (ex.IsFatal())
                {
                    throw;
                }
            }

            try
            {
                _storageProvider.DeleteFolder(_stylesPath);
                Thread.Sleep(300);
            }
            catch (Exception ex)
            {
                if (ex.IsFatal())
                {
                    throw;
                }
            }

            try
            {
                _storageProvider.DeleteFolder(_rootPath);
            }
            catch (Exception ex)
            {
                if (ex.IsFatal())
                {
                    throw;
                }
            }

            _combinatorEventHandler.CacheEmptied();
        }