// Simple test to verify locking system is "working". On // NFS, if it's misconfigured, you can hit long (35 // second) timeouts which cause Lock.obtain to take far // too long (it assumes the obtain() call takes zero // time). private void AcquireTestLock() { lock (this) { if (tested) { return; } tested = true; // Ensure that lockDir exists and is a directory. bool tmpBool; if (System.IO.File.Exists(lockDir.FullName)) { tmpBool = true; } else { tmpBool = System.IO.Directory.Exists(lockDir.FullName); } if (!tmpBool) { try { System.IO.Directory.CreateDirectory(lockDir.FullName); } catch { throw new System.SystemException("Cannot create directory: " + lockDir.FullName); } } else if (!System.IO.Directory.Exists(lockDir.FullName)) { throw new System.SystemException("Found regular file where directory expected: " + lockDir.FullName); } System.String randomLockName = "lucene-" + System.Convert.ToString(new System.Random().Next(), 16) + "-test.lock"; Lock l = MakeLock(randomLockName); try { l.Obtain(); l.Release(); } catch (System.IO.IOException e) { System.SystemException e2 = new System.SystemException("Failed to acquire random test lock; please verify filesystem for lock directory '" + lockDir + "' supports locking", e); throw e2; } } }
public async Task <HttpResponseMessage> UploadFiles(long inArticleId) { if (Request.Content.IsMimeMultipartContent()) { var streamProvider = await Request. Content. ReadAsMultipartAsync(new MultipartMemoryStreamProvider()); #if FILES_TO_FILESYSTEM System.SystemException error = await _fileService.PutFiles(streamProvider, inArticleId, HttpContext. Current. Server. MapPath("~/Files")); #else System.SystemException error = await _fileService.PuFiles(streamProvider, inArticleId); #endif if (error != null) { throw new HttpResponseException ( Request. CreateResponse ( HttpStatusCode.InternalServerError, error.Message ) ); } } else { throw new HttpResponseException ( Request. CreateResponse ( HttpStatusCode.NotAcceptable, "This request is not properly formatted" ) ); } return(Request.CreateResponse(HttpStatusCode.OK)); }
public async Task <IHttpActionResult> DeleteArticleFiles(long inArticleId) { #if FILES_TO_FILESYSTEM System.SystemException error = await _fileService. DeleteArticleFiles(inArticleId, HttpContext. Current. Server. MapPath("~/Files")); #else System.SystemException error = await _fileService.DeleteArticleFiles(inArticleId); #endif if (error == null) { return(Ok()); } else { return(BadRequest(error.Message)); } }
/// <summary> Clears the current target error conditions, if any. Note that a thread /// in the pool might have set the error conditions since the last check /// and that those error conditions will be lost. Likewise, before /// returning from this method another thread might set the error /// conditions. There is no guarantee that no error conditions exist when /// returning from this method. /// /// <P>In order to ensure that no error conditions exist when returning /// from this method cooperation from the targets and the thread using this /// pool is necessary (i.e. currently no targets running or waiting to /// run). /// /// </summary> public virtual void clearTargetErrors() { // Clear the error and runtime exception conditions targetE = null; targetRE = null; }