Bug: 573770 Change-Id: I78e1c7d3e042eaef64e85bc546af207478f2e334changes/06/182906/5
/* | |||||
* Copyright (C) 2010, Google Inc. and others | |||||
* | |||||
* This program and the accompanying materials are made available under the | |||||
* terms of the Eclipse Distribution License v. 1.0 which is available at | |||||
* https://www.eclipse.org/org/documents/edl-v10.php. | |||||
* | |||||
* SPDX-License-Identifier: BSD-3-Clause | |||||
*/ | |||||
package org.eclipse.jgit.errors; | |||||
import org.eclipse.jgit.internal.storage.file.Pack; | |||||
/** | |||||
* A previously selected representation is no longer available. | |||||
*/ | |||||
public class StoredPackRepresentationNotAvailableException extends Exception { | |||||
//TODO remove unused ObjectToPack in 5.0 | |||||
private static final long serialVersionUID = 1L; | |||||
/** | |||||
* Construct an error for an object. | |||||
* | |||||
* @param pack | |||||
* the object whose current representation is no longer present. | |||||
* @param cause | |||||
* cause | |||||
* @since 5.13 | |||||
*/ | |||||
public StoredPackRepresentationNotAvailableException(Pack pack, | |||||
Throwable cause) { | |||||
super(cause); | |||||
// Do nothing. | |||||
} | |||||
} |
import java.io.IOException; | import java.io.IOException; | ||||
import java.util.List; | import java.util.List; | ||||
import org.eclipse.jgit.errors.StoredObjectRepresentationNotAvailableException; | |||||
import org.eclipse.jgit.errors.StoredPackRepresentationNotAvailableException; | |||||
import org.eclipse.jgit.internal.storage.pack.CachedPack; | import org.eclipse.jgit.internal.storage.pack.CachedPack; | ||||
import org.eclipse.jgit.internal.storage.pack.ObjectToPack; | import org.eclipse.jgit.internal.storage.pack.ObjectToPack; | ||||
import org.eclipse.jgit.internal.storage.pack.PackExt; | import org.eclipse.jgit.internal.storage.pack.PackExt; | ||||
} | } | ||||
void copyAsIs(PackOutputStream out, WindowCursor wc) | void copyAsIs(PackOutputStream out, WindowCursor wc) | ||||
throws IOException { | |||||
throws IOException, StoredPackRepresentationNotAvailableException { | |||||
for (Pack pack : getPacks()) | for (Pack pack : getPacks()) | ||||
pack.copyPackAsIs(out, wc); | pack.copyPackAsIs(out, wc); | ||||
} | } |
import org.eclipse.jgit.errors.PackInvalidException; | import org.eclipse.jgit.errors.PackInvalidException; | ||||
import org.eclipse.jgit.errors.PackMismatchException; | import org.eclipse.jgit.errors.PackMismatchException; | ||||
import org.eclipse.jgit.errors.StoredObjectRepresentationNotAvailableException; | import org.eclipse.jgit.errors.StoredObjectRepresentationNotAvailableException; | ||||
import org.eclipse.jgit.errors.StoredPackRepresentationNotAvailableException; | |||||
import org.eclipse.jgit.errors.UnpackException; | import org.eclipse.jgit.errors.UnpackException; | ||||
import org.eclipse.jgit.errors.UnsupportedPackIndexVersionException; | import org.eclipse.jgit.errors.UnsupportedPackIndexVersionException; | ||||
import org.eclipse.jgit.errors.UnsupportedPackVersionException; | import org.eclipse.jgit.errors.UnsupportedPackVersionException; | ||||
} | } | ||||
void copyPackAsIs(PackOutputStream out, WindowCursor curs) | void copyPackAsIs(PackOutputStream out, WindowCursor curs) | ||||
throws IOException { | |||||
throws IOException, StoredPackRepresentationNotAvailableException { | |||||
// Pin the first window, this ensures the length is accurate. | // Pin the first window, this ensures the length is accurate. | ||||
curs.pin(this, 0); | curs.pin(this, 0); | ||||
curs.copyPackAsIs(this, length, out); | curs.copyPackAsIs(this, length, out); |
import org.eclipse.jgit.errors.IncorrectObjectTypeException; | import org.eclipse.jgit.errors.IncorrectObjectTypeException; | ||||
import org.eclipse.jgit.errors.MissingObjectException; | import org.eclipse.jgit.errors.MissingObjectException; | ||||
import org.eclipse.jgit.errors.StoredObjectRepresentationNotAvailableException; | import org.eclipse.jgit.errors.StoredObjectRepresentationNotAvailableException; | ||||
import org.eclipse.jgit.errors.StoredPackRepresentationNotAvailableException; | |||||
import org.eclipse.jgit.internal.JGitText; | import org.eclipse.jgit.internal.JGitText; | ||||
import org.eclipse.jgit.internal.storage.pack.CachedPack; | import org.eclipse.jgit.internal.storage.pack.CachedPack; | ||||
import org.eclipse.jgit.internal.storage.pack.ObjectReuseAsIs; | import org.eclipse.jgit.internal.storage.pack.ObjectReuseAsIs; | ||||
/** {@inheritDoc} */ | /** {@inheritDoc} */ | ||||
@Override | @Override | ||||
public void copyPackAsIs(PackOutputStream out, CachedPack pack) | public void copyPackAsIs(PackOutputStream out, CachedPack pack) | ||||
throws IOException { | |||||
throws IOException, StoredPackRepresentationNotAvailableException { | |||||
((LocalCachedPack) pack).copyAsIs(out, this); | ((LocalCachedPack) pack).copyAsIs(out, this); | ||||
} | } | ||||
void copyPackAsIs(final Pack pack, final long length, | void copyPackAsIs(final Pack pack, final long length, | ||||
final PackOutputStream out) throws IOException { | |||||
final PackOutputStream out) throws IOException, StoredPackRepresentationNotAvailableException { | |||||
long position = 12; | long position = 12; | ||||
long remaining = length - (12 + 20); | long remaining = length - (12 + 20); | ||||
while (0 < remaining) { | while (0 < remaining) { | ||||
pin(pack, position); | |||||
int ptr = (int) (position - window.start); | |||||
int n = (int) Math.min(window.size() - ptr, remaining); | |||||
window.write(out, position, n); | |||||
position += n; | |||||
remaining -= n; | |||||
boolean reloadedPacks = false; | |||||
COPYPACK: for (; ; ) { | |||||
try { | |||||
pin(pack, position); | |||||
int ptr = (int) (position - window.start); | |||||
int n = (int) Math.min(window.size() - ptr, remaining); | |||||
window.write(out, position, n); | |||||
position += n; | |||||
remaining -= n; | |||||
} catch(IOException e){ | |||||
if (reloadedPacks) { | |||||
throw new StoredPackRepresentationNotAvailableException(pack, e); | |||||
} else { | |||||
reloadedPacks = true; | |||||
WindowCache.purge(pack); | |||||
continue COPYPACK; | |||||
} | |||||
} | |||||
break COPYPACK; | |||||
} | |||||
} | } | ||||
} | } | ||||
import org.eclipse.jgit.errors.MissingObjectException; | import org.eclipse.jgit.errors.MissingObjectException; | ||||
import org.eclipse.jgit.errors.StoredObjectRepresentationNotAvailableException; | import org.eclipse.jgit.errors.StoredObjectRepresentationNotAvailableException; | ||||
import org.eclipse.jgit.errors.StoredPackRepresentationNotAvailableException; | |||||
import org.eclipse.jgit.lib.AnyObjectId; | import org.eclipse.jgit.lib.AnyObjectId; | ||||
import org.eclipse.jgit.lib.BitmapIndex.BitmapBuilder; | import org.eclipse.jgit.lib.BitmapIndex.BitmapBuilder; | ||||
import org.eclipse.jgit.lib.ProgressMonitor; | import org.eclipse.jgit.lib.ProgressMonitor; | ||||
* the pack cannot be read, or stream did not accept a write. | * the pack cannot be read, or stream did not accept a write. | ||||
*/ | */ | ||||
void copyPackAsIs(PackOutputStream out, CachedPack pack) | void copyPackAsIs(PackOutputStream out, CachedPack pack) | ||||
throws IOException; | |||||
throws IOException, StoredPackRepresentationNotAvailableException; | |||||
/** | /** | ||||
* Obtain the available cached packs that match the bitmap and update | * Obtain the available cached packs that match the bitmap and update |
import org.eclipse.jgit.errors.MissingObjectException; | import org.eclipse.jgit.errors.MissingObjectException; | ||||
import org.eclipse.jgit.errors.SearchForReuseTimeout; | import org.eclipse.jgit.errors.SearchForReuseTimeout; | ||||
import org.eclipse.jgit.errors.StoredObjectRepresentationNotAvailableException; | import org.eclipse.jgit.errors.StoredObjectRepresentationNotAvailableException; | ||||
import org.eclipse.jgit.errors.StoredPackRepresentationNotAvailableException; | |||||
import org.eclipse.jgit.internal.JGitText; | import org.eclipse.jgit.internal.JGitText; | ||||
import org.eclipse.jgit.internal.storage.file.PackBitmapIndexBuilder; | import org.eclipse.jgit.internal.storage.file.PackBitmapIndexBuilder; | ||||
import org.eclipse.jgit.internal.storage.file.PackBitmapIndexWriterV1; | import org.eclipse.jgit.internal.storage.file.PackBitmapIndexWriterV1; | ||||
} | } | ||||
writeChecksum(out); | writeChecksum(out); | ||||
out.flush(); | out.flush(); | ||||
} catch (StoredPackRepresentationNotAvailableException s) { | |||||
//XXX Log cannot load packfile... | |||||
} finally { | } finally { | ||||
stats.timeWriting = System.currentTimeMillis() - writeStart; | stats.timeWriting = System.currentTimeMillis() - writeStart; | ||||
stats.depth = depth; | stats.depth = depth; |