diff options
author | James Moger <james.moger@gitblit.com> | 2012-12-03 21:29:32 -0500 |
---|---|---|
committer | James Moger <james.moger@gitblit.com> | 2012-12-03 21:29:32 -0500 |
commit | 8ee931e0a051b73c1128e8fa73ead9084c6d2e09 (patch) | |
tree | 42a3c6af6596d8a84e6f8adac2ba7e1ab96dc6e1 /src/com/gitblit | |
parent | e5662e85681deb98e2ed65831ade3f066f29f154 (diff) | |
download | gitblit-8ee931e0a051b73c1128e8fa73ead9084c6d2e09.tar.gz gitblit-8ee931e0a051b73c1128e8fa73ead9084c6d2e09.zip |
Fixes to symlink handling (issue-174)
Diffstat (limited to 'src/com/gitblit')
-rw-r--r-- | src/com/gitblit/utils/CompressionUtils.java | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/src/com/gitblit/utils/CompressionUtils.java b/src/com/gitblit/utils/CompressionUtils.java index 41451906..a8dcdd8f 100644 --- a/src/com/gitblit/utils/CompressionUtils.java +++ b/src/com/gitblit/utils/CompressionUtils.java @@ -27,6 +27,7 @@ import org.apache.commons.compress.archivers.zip.ZipArchiveEntry; import org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream;
import org.apache.commons.compress.compressors.CompressorException;
import org.apache.commons.compress.compressors.CompressorStreamFactory;
+import org.apache.wicket.util.io.ByteArrayOutputStream;
import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.FileMode;
import org.eclipse.jgit.lib.MutableObjectId;
@@ -256,7 +257,6 @@ public class CompressionUtils { }
tw.setRecursive(true);
MutableObjectId id = new MutableObjectId();
- ObjectReader reader = tw.getObjectReader();
long modified = commit.getAuthorIdent().getWhen().getTime();
while (tw.next()) {
FileMode mode = tw.getFileMode(0);
@@ -265,16 +265,24 @@ public class CompressionUtils { }
tw.getObjectId(id, 0);
- TarArchiveEntry entry = new TarArchiveEntry(tw.getPathString());
- entry.setSize(reader.getObjectSize(id, Constants.OBJ_BLOB));
-
- entry.setMode(mode.getBits());
- entry.setModTime(modified);
- tos.putArchiveEntry(entry);
-
- ObjectLoader ldr = repository.open(id);
- ldr.copyTo(tos);
- tos.closeArchiveEntry();
+ ObjectLoader loader = repository.open(id);
+ if (FileMode.SYMLINK == mode) {
+ TarArchiveEntry entry = new TarArchiveEntry(tw.getPathString(),TarArchiveEntry.LF_SYMLINK);
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ loader.copyTo(bos);
+ entry.setLinkName(bos.toString());
+ entry.setModTime(modified);
+ tos.putArchiveEntry(entry);
+ tos.closeArchiveEntry();
+ } else {
+ TarArchiveEntry entry = new TarArchiveEntry(tw.getPathString());
+ entry.setMode(mode.getBits());
+ entry.setModTime(modified);
+ entry.setSize(loader.getSize());
+ tos.putArchiveEntry(entry);
+ loader.copyTo(tos);
+ tos.closeArchiveEntry();
+ }
}
tos.finish();
tos.close();
|