salesforce / zsync4j Goto Github PK
View Code? Open in Web Editor NEWJava port of zsync
License: BSD 3-Clause "New" or "Revised" License
Java port of zsync
License: BSD 3-Clause "New" or "Revised" License
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
in
0 and contentLengh() are passed in to create the ContentRange(). Shouldn't the first be 0 and last be contentLength() -1 ?
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.
/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\"");
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
Could this be released to central, or at least, any plans doing so?
Thanks
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();
}
Salesforce is in the process of migrating all repositories from github.com/SalesforceEng to github.com/salesforce. As a part of this migration, this repository is slated to be moved as well. To request an exception or for any concerns contact @SalesforceEng/osscore or email [email protected]. There is no set date for the migration yet. For details on how GitHub repository transfers work, see here. Posted at 2016-08-23 22:42:26 PST.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.