コード例 #1
0
    public static ObjectStat getFileStat(
        OSSObjectOperation objectOperation, String bucketName, String key) {
      GenericRequest genericRequest = new GenericRequest(bucketName, key);
      SimplifiedObjectMeta meta = objectOperation.getSimplifiedObjectMeta(genericRequest);

      ObjectStat objStat = new ObjectStat();
      objStat.size = meta.getSize();
      objStat.lastModified = meta.getLastModified();
      objStat.digest = meta.getETag();

      return objStat;
    }
コード例 #2
0
    /** 判读Object与checkpoint中记录的信息是否相符,即Object是否修改过 */
    public synchronized boolean isValid(OSSObjectOperation objectOperation) {
      // 比较checkpoint的magic和md5
      if (this.magic == null || !this.magic.equals(DOWNLOAD_MAGIC) || this.md5 != hashCode()) {
        return false;
      }

      GenericRequest genericRequest = new GenericRequest(bucketName, objectKey);
      SimplifiedObjectMeta meta = objectOperation.getSimplifiedObjectMeta(genericRequest);

      // Object的大小、最后修改时间、ETAG相同
      if (this.objectStat.size != meta.getSize()
          || !this.objectStat.lastModified.equals(meta.getLastModified())
          || !this.objectStat.digest.equals(meta.getETag())) {
        return false;
      }

      return true;
    }