Giter Site home page Giter Site logo

zsync4j's People

Contributors

brianstclair-sfdc avatar busjaeger avatar ifedorenko avatar jvanzyl avatar svc-scm avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

zsync4j's Issues

IIS Server not returning expected format for multipart Content-Type

/zsync-core/src/main/java/com/salesforce/zsync/internal/util/HttpClient.java#L425
MediaType.parse() doesn't expect the format of the Content-Type header to be as provided by an older IIS Server version and results in error "Could not parse 'multipart/byteranges"

To workaround this issue:

Remove final from:
/zsync-core/src/main/java/com/salesforce/zsync/internal/util/HttpClient.java#L421

And insert the follwing code line before:
/zsync-core/src/main/java/com/salesforce/zsync/internal/util/HttpClient.java#L425

contentType = contentType.replaceFirst("multipart/byteranges; boundary=(<[^>]*?>)", "multipart/byteranges; boundary=\"$1\"");

Unexpected error during digest computation, Wrong offset or not enough space to store the digest

The source code has a copy of org.apache.mina.proxy.utils.MD4.java , but its method

protected int engineDigest(byte[] buf, int offset, int len)

has offset + len > buf.length instead of offset + len >= buf.length (that e.g. mina 2.0.4 has).

If the parent project imports a version of mina that has ">=", a sync from an existing file sometimes (probably for very specific file content or size) yield the following Exception:

java.lang.RuntimeException: Unexpected error during digest computation
at com.salesforce.zsync.internal.Checksum.setChecksum(Checksum.java:86)
at com.salesforce.zsync.internal.DoubleBlockMatcher.tryMatchBoth(DoubleBlockMatcher.java:170)
at com.salesforce.zsync.internal.DoubleBlockMatcher.match(DoubleBlockMatcher.java:99)
at com.salesforce.zsync.Zsync.processInputFile(Zsync.java:449)
at com.salesforce.zsync.Zsync.processInputFiles(Zsync.java:430)
at com.salesforce.zsync.Zsync.zsyncInternal(Zsync.java:361)
at com.salesforce.zsync.Zsync.zsync(Zsync.java:314)
...
Suppressed: com.salesforce.zsync.internal.ChecksumValidationIOException
at com.salesforce.zsync.internal.OutputFileWriter.close(OutputFileWriter.java:213)
at com.salesforce.zsync.Zsync.zsyncInternal(Zsync.java:365)
... 12 more
Caused by: java.security.DigestException: Wrong offset or not enough space to store the digest
at org.apache.mina.proxy.utils.MD4.engineDigest(MD4.java:163)
at java.security.MessageDigest$Delegate.engineDigest(MessageDigest.java:593)
at java.security.MessageDigest.digest(MessageDigest.java:392)
at com.salesforce.zsync.internal.Checksum.setChecksum(Checksum.java:84)
... 17 more

That specific exception was for offset = 0 and len = 16, and buf.length = 16 .
It seems to be pretty much the only .java file of the source code that has a package outside com.salesforce.zsync, we may want to change the package to prevent that problem.

My workaround was to remove the other dependency/import that used Mina.

Missed Locale.US

Here and here should be used Locale.US as last argument for SimpleDateFormat to avoid ParseException for non-English locales.
zsync-core/src/main/java/com/salesforce/zsync/internal/Header.java#L125
zsync-core/src/main/java/com/salesforce/zsync/ZsyncMake.java#L64

"Text file busy" (from sun.nio.fs.UnixCopyFile.move(UnixCopyFile.java:455))

zsync-core/src/main/java/com/salesforce/zsync/internal/OutputFileWriter.java#L214
With Java OpenJDK 1.7.0_181 under a Docker container running in VirtualBox 5.2.8 and sharing a Windows folder to the Linux VM, Files.move gives the error :
"Text file busy" (from sun.nio.fs.UnixCopyFile.move(UnixCopyFile.java:455))

To fix, close the channel before the move:
Enclose lines:
zsync-core/src/main/java/com/salesforce/zsync/internal/OutputFileWriter.java#L209
to
zsync-core/src/main/java/com/salesforce/zsync/internal/OutputFileWriter.java#L213
in a try-finally block and move
zsync-core/src/main/java/com/salesforce/zsync/internal/OutputFileWriter.java#L221
to the finally part of that new try-finally

Final result:

try {
  try {
    this.channel.position(0); // reset channel to beginning to compute full SHA1
    String calculatedSha1 = ZsyncUtil.computeSha1(this.channel);
    if (!this.sha1.equals(calculatedSha1)) {
      throw new ChecksumValidationIOException(this.sha1, calculatedSha1);
    }
  } finally {
    this.channel.close(); 
  }
  
  try {
    Files.move(this.tempPath, this.path, REPLACE_EXISTING, ATOMIC_MOVE);
  } catch (AtomicMoveNotSupportedException e) {
    Files.move(this.tempPath, this.path, REPLACE_EXISTING);
  }
  Files.setLastModifiedTime(this.path, fromMillis(this.mtime));
} finally {
  this.listener.close();
}

Release to central?

Could this be released to central, or at least, any plans doing so?

Thanks

Long type should be used

Here should be used long type for first argument to support huge files.
zsync-core/src/main/java/com/salesforce/zsync/internal/OutputFileWriter.java#L139

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.