Another attempt at Linux fix for filesystem differences between Linux and Windows

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@2187 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Derek Hulley
2006-01-24 18:37:28 +00:00
parent 29da65708a
commit 97792d6afa
2 changed files with 20 additions and 11 deletions

View File

@@ -433,17 +433,12 @@ public abstract class AbstractContentReadWriteTest extends TestCase
os.write(content.getBytes()); os.write(content.getBytes());
os.flush(); // make sure that the bytes get persisted os.flush(); // make sure that the bytes get persisted
// with the stream open, attempt to delete the content
boolean deleted = store.delete(contentUrl);
// close the stream // close the stream
os.close(); os.close();
// get a reader // get a reader
ContentReader reader = store.getReader(contentUrl); ContentReader reader = store.getReader(contentUrl);
assertNotNull(reader); assertNotNull(reader);
// make sure that the underlying content still exists (the delete occured during a write)
assertTrue("Underlying content was deleted during a write", reader.exists());
ContentReader readerCheck = writer.getReader(); ContentReader readerCheck = writer.getReader();
assertNotNull(readerCheck); assertNotNull(readerCheck);
@@ -454,8 +449,7 @@ public abstract class AbstractContentReadWriteTest extends TestCase
InputStream is = reader.getContentInputStream(); InputStream is = reader.getContentInputStream();
// attempt to delete the content // attempt to delete the content
deleted = store.delete(contentUrl); boolean deleted = store.delete(contentUrl);
assertFalse("Content deletion failed to detect active reader", deleted);
// close the reader stream // close the reader stream
is.close(); is.close();
@@ -463,7 +457,19 @@ public abstract class AbstractContentReadWriteTest extends TestCase
// get a fresh reader // get a fresh reader
reader = store.getReader(contentUrl); reader = store.getReader(contentUrl);
assertNotNull(reader); assertNotNull(reader);
// the underlying system may or may not have deleted the content
if (deleted)
{
assertFalse("Content should not exist", reader.exists());
// drop out here
return;
}
else
{
assertTrue("Content should exist", reader.exists()); assertTrue("Content should exist", reader.exists());
}
// delete the content // delete the content
store.delete(contentUrl); store.delete(contentUrl);

View File

@@ -300,12 +300,15 @@ public class FileContentStore extends AbstractContentStore
{ {
// ignore files that don't exist // ignore files that don't exist
File file = makeFile(contentUrl); File file = makeFile(contentUrl);
boolean deleted = false;
if (!file.exists()) if (!file.exists())
{ {
return true; deleted = true;
}
else
{
deleted = file.delete();
} }
// attempt to delete the file directly
boolean deleted = file.delete();
// done // done
if (logger.isDebugEnabled()) if (logger.isDebugEnabled())