Esempio n. 1
0
 @Override
 public String prettyPrint() {
   String contents =
       digest != null
           ? String.format("digest of ", Arrays.toString(digest))
           : contentsProxy.prettyPrint();
   String extra = mtime != -1 ? String.format(" and mtime of %d", mtime) : "";
   return String.format("regular file with size of %d and %s%s", size, contents, extra);
 }
Esempio n. 2
0
 static SpecialFileStateValue fromStat(
     FileStatusWithDigest stat, @Nullable TimestampGranularityMonitor tsgm) throws IOException {
   long mtime = stat.getLastModifiedTime();
   // Note that TimestampGranularityMonitor#notifyDependenceOnFileTime is a thread-safe
   // method.
   if (tsgm != null) {
     tsgm.notifyDependenceOnFileTime(mtime);
   }
   return new SpecialFileStateValue(FileContentsProxy.create(mtime, stat.getNodeId()));
 }
Esempio n. 3
0
 /**
  * Create a FileFileStateValue instance corresponding to the given existing file.
  *
  * @param stat must be of type "File". (Not a symlink).
  */
 private static RegularFileStateValue fromPath(
     Path path, FileStatusWithDigest stat, @Nullable TimestampGranularityMonitor tsgm)
     throws InconsistentFilesystemException {
   Preconditions.checkState(stat.isFile(), path);
   try {
     byte[] digest = stat.getDigest();
     if (digest == null) {
       digest = path.getFastDigest();
     }
     if (digest == null) {
       long mtime = stat.getLastModifiedTime();
       // Note that TimestampGranularityMonitor#notifyDependenceOnFileTime is a thread-safe
       // method.
       if (tsgm != null) {
         tsgm.notifyDependenceOnFileTime(mtime);
       }
       return new RegularFileStateValue(
           stat.getSize(),
           stat.getLastModifiedTime(),
           null,
           FileContentsProxy.create(mtime, stat.getNodeId()));
     } else {
       // We are careful here to avoid putting the value ID into FileMetadata if we already have
       // a digest. Arbitrary filesystems may do weird things with the value ID; a digest is more
       // robust.
       return new RegularFileStateValue(
           stat.getSize(), stat.getLastModifiedTime(), digest, null);
     }
   } catch (IOException e) {
     String errorMessage =
         e.getMessage() != null ? "error '" + e.getMessage() + "'" : "an error";
     throw new InconsistentFilesystemException(
         "'stat' said "
             + path
             + " is a file but then we "
             + "later encountered "
             + errorMessage
             + " which indicates that "
             + path
             + " is no "
             + "longer a file. Did you delete it during the build?");
   }
 }
Esempio n. 4
0
 @Override
 public String prettyPrint() {
   return String.format("special file with %s", contentsProxy.prettyPrint());
 }
Esempio n. 5
0
 @Override
 public int hashCode() {
   return contentsProxy.hashCode();
 }