Skip to content

Commit

Permalink
upstream: b=master,r=77d5e247585d3eeb3a73d5df0e21b5f12006cfcd,t=2016-…
Browse files Browse the repository at this point in the history
…04-12-0623-45440
  • Loading branch information
sonatype-zion committed Apr 12, 2016
1 parent 85b3e53 commit b2c18dc
Show file tree
Hide file tree
Showing 7 changed files with 656 additions and 10,368 deletions.
2 changes: 1 addition & 1 deletion buildsupport/insight/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

<properties>
<sonatype-licensing.version>1.4</sonatype-licensing.version>
<insight-brain.version>1.20.0-SNAPSHOT</insight-brain.version>
<insight-brain.version>1.20.0-02</insight-brain.version>
<insight-scanner.version>2.3.2</insight-scanner.version>
</properties>

Expand Down
10,931 changes: 583 additions & 10,348 deletions components/nexus-core/nexus-work_IS_UNDEFINED/logs/nexus.log

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -1479,7 +1479,7 @@ protected AbstractStorageItem doRetrieveRemoteItem(ResourceStoreRequest request)
if (log.isDebugEnabled()) {
logFailedUrl(remoteUrl, e);
}
// not debug, only print the message
// not debug, print root stacktrace
else {
Throwable t = ExceptionUtils.getRootCause(e);

Expand All @@ -1488,10 +1488,11 @@ protected AbstractStorageItem doRetrieveRemoteItem(ResourceStoreRequest request)
}

log.error(
"Got LocalStorageException in proxy repository {} while caching retrieved artifact \"{}\" got from URL {}, will attempt next mirror",
"Got LocalStorageException in proxy repository {} while caching retrieved artifact \"{}\" got from URL {}, this is {} (re)try",
RepositoryStringUtils.getHumanizedNameString(this),
request,
remoteUrl,
String.valueOf(i + 1),
t
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -267,17 +267,25 @@ public boolean deletePackages(final NpmRepository repository) {
checkNotNull(repository);
final EntityHandler<PackageRoot> entityHandler = getHandlerFor(PackageRoot.class);
try (ODatabaseDocumentTx db = db()) {
db.begin();
try {
int recordsDeleted = db.command(
new OCommandSQL(
"delete from " + entityHandler.getSchemaName() + " where repositoryId='" + repository.getId() + "'"
)
).execute();
return recordsDeleted > 0;
}
finally {
db.commit();
int recordsDeleted = 0, totalDeleted = 0;
while (true) {
db.begin();
try {
recordsDeleted = db.command(
new OCommandSQL(
"delete from " + entityHandler.getSchemaName() + " where repositoryId='" + repository.getId() + "' limit 1000"
)
).execute();
}
finally {
db.commit();
}
if (recordsDeleted > 0) {
totalDeleted += recordsDeleted;
}
else {
return totalDeleted > 0;
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,17 @@
*/
package org.sonatype.nexus.plugins.ruby.proxy;

import java.io.File;

import javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Singleton;

import org.sonatype.nexus.mime.MimeSupport;
import org.sonatype.nexus.plugins.ruby.NexusRubygemsFacade;
import org.sonatype.nexus.proxy.ItemNotFoundException;
import org.sonatype.nexus.proxy.LocalStorageException;
import org.sonatype.nexus.proxy.ResourceStoreRequest;
import org.sonatype.nexus.proxy.item.AbstractStorageItem;
import org.sonatype.nexus.proxy.item.LinkPersister;
import org.sonatype.nexus.proxy.item.StorageItem;
Expand Down Expand Up @@ -61,10 +65,50 @@ public void storeItem(Repository repository, StorageItem item)
RubygemsFile file = fileSystem.file(item.getResourceStoreRequest());

if (file.type() != FileType.NOT_FOUND) {
item.getResourceStoreRequest().setRequestPath(file.storagePath());
((AbstractStorageItem) item).setPath(file.storagePath());
item.getResourceStoreRequest().setRequestPath(file.storagePath());
((AbstractStorageItem) item).setPath(file.storagePath());
}
}
super.storeItem(repository, item);
}

@Override
public AbstractStorageItem retrieveItem(final Repository repository, final ResourceStoreRequest request)
throws ItemNotFoundException, LocalStorageException
{
if (!request.getRequestPath().startsWith("/.nexus")) {
RubygemsFile file = fileSystem.file(request);

if (file.type() == FileType.BUNDLER_API || file.type() == FileType.DEPENDENCY) {
request.pushRequestPath(file.storagePath());
try {
return super.retrieveItem(repository, request);
}
finally {
request.popRequestPath();
}
}
}
return super.retrieveItem(repository, request);
}

@Override
public boolean containsItem(final Repository repository, final ResourceStoreRequest request)
throws LocalStorageException
{
if (!request.getRequestPath().startsWith("/.nexus")) {
RubygemsFile file = fileSystem.file(request);

if (file.type() == FileType.BUNDLER_API || file.type() == FileType.DEPENDENCY) {
request.pushRequestPath(file.storagePath());
try {
return super.containsItem(repository, request);
}
finally {
request.popRequestPath();
}
}
}
return super.containsItem(repository, request);
}
}
2 changes: 1 addition & 1 deletion revision.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
b=master,r=8be2942c4424be5b2cb40d15cc316d8b9fd72d43,t=2016-03-08-0448-45717
b=master,r=77d5e247585d3eeb3a73d5df0e21b5f12006cfcd,t=2016-04-12-0623-45440
Original file line number Diff line number Diff line change
Expand Up @@ -137,12 +137,12 @@ public void exerciseDependencyCaching() throws Exception {
scheduler().run("ExpireCacheTask", null);
scheduler().waitForAllTasksToStop(); // wait for it

// expect single GET of expired dependencies list
// expect HEAD+GET to re-fetch expired dependencies list
proxyRecord.clear();
requestGemDependencies();
requestGemDependencies();
requestGemDependencies();
assertThat(proxyRecord.getRequests(), hasSize(1));
assertThat(proxyRecord.getRequests(), hasSize(2));
}

private void requestGemDependencies() throws IOException {
Expand All @@ -168,4 +168,4 @@ private void requestNoneExistingGem() throws IOException {
}
download.deleteOnExit();
}
}
}

0 comments on commit b2c18dc

Please sign in to comment.