Exemplo n.º 1
0
        /// <summary>
        /// Purges all assets that have the "local" flag set from both disk and memory.
        /// Never touches the remotes.
        /// </summary>
        public void PurgeAllLocalAssets()
        {
            IChattelLocalStorage chattelStorage = _localStorage;

            chattelStorage.PurgeAll(new List <AssetFilter> {
                new AssetFilter {
                    LocalFilter = true,
                }
            });
        }
Exemplo n.º 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="T:ChattelReader"/> class.
        /// If local storage is enabled, but no local storage instance was passed in, automatically sets up and uses the AssetStorageSimpleFolderTree for local storage.
        /// If purgeLocalStorage is set, purges all assets in the storage.
        /// </summary>
        /// <param name="config">Instance of the configuration class.</param>
        /// <param name="localStorage">Instance of the IChattelLocalStorage interface. If left null, then the default AssetStorageSimpleFolderTree will be instantiated.</param>
        /// <param name="purgeLocalStorage">Whether or not to attempt to purge local storage.</param>
        public ChattelReader(ChattelConfiguration config, IChattelLocalStorage localStorage, bool purgeLocalStorage)
        {
            _config = config ?? throw new ArgumentNullException(nameof(config));

            if (_config.LocalStorageEnabled)
            {
                _localStorage = localStorage ?? new AssetStorageSimpleFolderTree(config);
            }

            if (purgeLocalStorage)
            {
                _localStorage?.PurgeAll(null);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="T:ChattelWriter"/> class.
        /// </summary>
        /// <param name="config">Instance of the configuration class.</param>
        /// <param name="localStorage">Instance of the IChattelLocalStorage interface. If left null, then the default AssetStorageSimpleFolderTree will be instantiated.</param>
        /// <param name="purgeLocalStorage">Whether or not to attempt to purge local storage.</param>
        /// <exception cref="!:ChattelConfigurationException">Thrown if the are pending assets to be sent upstream and there are no upstream servers configured.</exception>
        public ChattelWriter(ChattelConfiguration config, IChattelLocalStorage localStorage, bool purgeLocalStorage)
        {
            _config = config ?? throw new ArgumentNullException(nameof(config));

            if (config.LocalStorageEnabled)
            {
                _localStorage = localStorage ?? new AssetStorageSimpleFolderTree(config);
            }

            if (purgeLocalStorage)
            {
                _localStorage?.PurgeAll(null);
            }

            if (config.LocalStorageEnabled && config.WriteCacheFile != null)
            {
                _writeCache = new WriteCache(config.WriteCacheFile, config.WriteCacheRecordCount, this, localStorage);
            }
        }
 public static void TestAssetLocalStorageLmdbPartitionedLRU_PurgeAll_Null_EmptyLocalStorage_DoesntThrow()
 {
     Assert.DoesNotThrow(() => _localStorage.PurgeAll(null));
 }
 public static void TestAssetLocalStorageLmdbCtor3NoLruPurge_PurgeAll_Null_EmptyLocalStorage_DoesntThrow()
 {
     Assert.DoesNotThrow(() => _localStorage.PurgeAll(null));
 }