private void HandlePurgeAsset(Guid assetId, Request req) { if (assetId == Guid.Empty) { req.ResponseHandler(new ServerResponseMsg(ServerResponseMsg.ResponseCode.RC_ERROR, assetId, "Zero UUID not allowed."), req.Context); } StorageManager.PurgeResult result = StorageManager.PurgeResult.NOT_FOUND_LOCALLY; var error = false; try { _storageManager.PurgeAsset(assetId, purgeResult => result = purgeResult); } catch (Exception e) { LOG.Debug($"Exception purging asset {assetId}", e); error = true; } if (error) { req.ResponseHandler(new ServerResponseMsg(ServerResponseMsg.ResponseCode.RC_ERROR, assetId, "Error processing request."), req.Context); } else { req.ResponseHandler(new ServerResponseMsg(result == StorageManager.PurgeResult.DONE ? ServerResponseMsg.ResponseCode.RC_OK : ServerResponseMsg.ResponseCode.RC_NOTFOUND, assetId), req.Context); } }
public static void TestStorageManager_PurgeAsset_Known_ReturnsDone() { LOG.Info($"Executing {nameof(TestStorageManager_PurgeAsset_Known_ReturnsDone)}"); var mgr = new StorageManager( _readerLocalStorage, TimeSpan.FromMinutes(2), _chattelReader, _chattelWriter ); var asset = new StratusAsset { Id = Guid.NewGuid(), }; var wait = new AutoResetEvent(false); mgr.StoreAsset(asset, result => wait.Set()); wait.WaitOne(); StorageManager.PurgeResult status = StorageManager.PurgeResult.NOT_FOUND_LOCALLY; wait.Reset(); mgr.PurgeAsset(asset.Id, result => { status = result; wait.Set(); }); wait.WaitOne(); Assert.AreEqual(StorageManager.PurgeResult.DONE, status); }