Look at replica status too in accessReplica().
authorFrantišek Dvořák <valtri@civ.zcu.cz>
Sun, 23 Feb 2014 12:08:31 +0000 (13:08 +0100)
committerFrantišek Dvořák <valtri@civ.zcu.cz>
Sun, 23 Feb 2014 13:16:21 +0000 (14:16 +0100)
src/VfsNs.cpp

index 567702d..f7d5d1d 100644 (file)
@@ -516,12 +516,28 @@ bool VfsCatalog::access(const std::string& path, int mode) throw (DmException)
 }
 
 
-bool VfsCatalog::accessReplica(const std::string& replica, int mode) throw (DmException)
+bool VfsCatalog::accessReplica(const std::string& rfn, int mode) throw (DmException)
 {
   std::string path;
+  Replica replica;
+  bool metaAllowed, replicaAllowed;
+
+  try {
+    replica = this->getReplicaByRFN(rfn);
+    if (mode & W_OK) {
+      replicaAllowed = (replica.status == Replica::kBeingPopulated);
+    } else {
+      replicaAllowed = true;
+    }
 
-  path = vfsPathByRFN(replica);
-  return this->access(path, mode);
+    path = vfsPathByRFN(rfn);
+    metaAllowed = this->access(path, mode);
+
+    return metaAllowed && replicaAllowed;
+  } catch (DmException& e) {
+    if (e.code() != EACCES) throw;
+    return false;
+  }
 }
 
 
@@ -1537,7 +1553,7 @@ Replica VfsCatalog::getReplicaByRFN(const std::string& rfn) throw (DmException)
 
   return replica;
 }
-        
+
 
 
 void VfsCatalog::updateReplica(const Replica& replica) throw (DmException)