jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thom...@apache.org
Subject svn commit: r979263 - /jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/data/FileDataStore.java
Date Mon, 26 Jul 2010 12:53:54 GMT
Author: thomasm
Date: Mon Jul 26 12:53:53 2010
New Revision: 979263

URL: http://svn.apache.org/viewvc?rev=979263&view=rev
Log:
JCR-2676 FileDataStore should check for lastModified error result

Modified:
    jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/data/FileDataStore.java

Modified: jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/data/FileDataStore.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/data/FileDataStore.java?rev=979263&r1=979262&r2=979263&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/data/FileDataStore.java
(original)
+++ jackrabbit/trunk/jackrabbit-core/src/main/java/org/apache/jackrabbit/core/data/FileDataStore.java
Mon Jul 26 12:53:53 2010
@@ -137,7 +137,11 @@ public class FileDataStore implements Da
                 return null;
             }
             if (minModifiedDate != 0 && file.canWrite()) {
-                if (file.lastModified() < minModifiedDate) {
+                long lastModified = file.lastModified();
+                if (lastModified == 0) {
+                    throw new DataStoreException("Failed to read record modified date: "
+ identifier);
+                } 
+                if (lastModified < minModifiedDate) {
                 	    // The current GC approach depends on this call succeeding
                     if (!file.setLastModified(System.currentTimeMillis() + ACCESS_TIME_RESOLUTION))
{
                         throw new DataStoreException("Failed to update record modified date:
" + identifier);
@@ -220,8 +224,12 @@ public class FileDataStore implements Da
                                 + " (media read only?)");
                     }
                 } else {
+                    long lastModified = file.lastModified();
+                    if (lastModified == 0) {
+                        throw new DataStoreException("Failed to read record modified date:
" + identifier);
+                    }
                     long now = System.currentTimeMillis();
-                    if (file.lastModified() < now + ACCESS_TIME_RESOLUTION) {
+                    if (lastModified < now + ACCESS_TIME_RESOLUTION) {
                         // The current GC approach depends on this call succeeding (for writable
files)
                         if (!file.setLastModified(now + ACCESS_TIME_RESOLUTION)) {
                             if (file.canWrite()) {
@@ -299,16 +307,21 @@ public class FileDataStore implements Da
         int count = 0;
         if (file.isFile() && file.exists() && file.canWrite()) {
             synchronized (this) {
-                String fileName = file.getName();
-                if (file.lastModified() < min) {
-                    DataIdentifier id = new DataIdentifier(fileName);
+                long lastModified = file.lastModified();
+                if (lastModified == 0) {
+                    // Don't delete the file, since the lastModified date is uncertain!
+                    log.warn("Failed to read modification date for " + file.getAbsolutePath());
+                } else if (lastModified < min) {
+                    DataIdentifier id = new DataIdentifier(file.getName());
                     if (!inUse.containsKey(id)) {
                         if (log.isInfoEnabled()) {
                             log.info("Deleting old file " + file.getAbsolutePath() +
-                                    " modified: " + new Timestamp(file.lastModified()).toString()
+
+                                    " modified: " + new Timestamp(lastModified).toString()
+
                                     " length: " + file.length());
                         }
-                        file.delete();
+                        if (!file.delete()) {
+                            log.warn("Failed to delete old file " + file.getAbsolutePath());
+                        }
                         count++;
                     }
                 }



Mime
View raw message