🚧 Add fix for not found hashes
This commit is contained in:
parent
4f6f71ecd5
commit
d604ca1601
@ -23,7 +23,8 @@ public class Jar
|
||||
|
||||
private String url;
|
||||
|
||||
private String filename;
|
||||
@Column(name = "file_base")
|
||||
private String fileBase;
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "version_id")
|
||||
@ -96,14 +97,14 @@ public class Jar
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getFilename()
|
||||
public String getFileBase()
|
||||
{
|
||||
return filename;
|
||||
return fileBase;
|
||||
}
|
||||
|
||||
public Jar setFilename(String filename)
|
||||
public Jar setFileBase(String filename)
|
||||
{
|
||||
this.filename = filename;
|
||||
this.fileBase = filename;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
@ -23,7 +23,8 @@ public class Pom
|
||||
|
||||
private String url;
|
||||
|
||||
private String filename;
|
||||
@Column(name = "file_base")
|
||||
private String fileBase;
|
||||
|
||||
@OneToOne
|
||||
@JoinColumn(name = "version_id")
|
||||
@ -96,14 +97,14 @@ public class Pom
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getFilename()
|
||||
public String getFileBase()
|
||||
{
|
||||
return filename;
|
||||
return fileBase;
|
||||
}
|
||||
|
||||
public Pom setFilename(String filename)
|
||||
public Pom setFileBase(String fileBase)
|
||||
{
|
||||
this.filename = filename;
|
||||
this.fileBase = fileBase;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
@ -177,11 +177,11 @@ public class Version
|
||||
pullCount = pullCount + 1;
|
||||
}
|
||||
|
||||
public Optional<Jar> getJarByFilename(String filename)
|
||||
public Optional<Jar> getJarByFileBase(String fileBase)
|
||||
{
|
||||
for (Jar jar : jars)
|
||||
{
|
||||
if (jar.getFilename().equals(filename))
|
||||
if (jar.getFileBase().equals(fileBase))
|
||||
{
|
||||
return Optional.of(jar);
|
||||
}
|
||||
|
||||
@ -23,9 +23,9 @@ public class JarService
|
||||
String md5 = DigestUtils.md5Hex(body);
|
||||
String sha1 = DigestUtils.sha1Hex(body);
|
||||
Version version = versionService.findOrCreate(mavenContext.groupId(), mavenContext.artifactId(), mavenContext.version().getRaw());
|
||||
if (!existsJar(version.getJars(), mavenContext.file().getRaw()))
|
||||
if (!existsJar(version.getJars(), mavenContext.file().getBase()))
|
||||
{
|
||||
version.getJars().add(new Jar().setJar(body).setMd5(md5).setSha1(sha1).setVersion(version).setUrl(mavenContext.path()).setFilename(mavenContext.file().getRaw()));
|
||||
version.getJars().add(new Jar().setJar(body).setMd5(md5).setSha1(sha1).setVersion(version).setUrl(mavenContext.path()).setFileBase(mavenContext.file().getBase()));
|
||||
versionService.persist(version);
|
||||
return Response.status(Response.Status.CREATED).build();
|
||||
}
|
||||
@ -55,14 +55,14 @@ public class JarService
|
||||
|
||||
private Jar findJar(MavenContext context)
|
||||
{
|
||||
return versionService.findOptional(context.groupId(), context.artifactId(), context.version().getRaw()).orElseThrow().getJarByFilename(context.file().getRaw()).orElseThrow();
|
||||
return versionService.findOptional(context.groupId(), context.artifactId(), context.version().getRaw()).orElseThrow().getJarByFileBase(context.file().getBase()).orElseThrow();
|
||||
}
|
||||
|
||||
private boolean existsJar(List<Jar> jars, String filename)
|
||||
private boolean existsJar(List<Jar> jars, String fileBase)
|
||||
{
|
||||
for (Jar jar : jars)
|
||||
{
|
||||
if (filename.equals(jar.getFilename()))
|
||||
if (fileBase.equals(jar.getFileBase()))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -24,7 +24,7 @@ public class MavenContextProvider
|
||||
case XML ->
|
||||
{
|
||||
MavenMetadataUrlParser parser = MavenMetadataUrlParser.parse(path);
|
||||
return new MavenContext(path, parser.groupId(), parser.artifactId(), null, new File().setType(result.ext()).setHash(result.hashExt()));
|
||||
return new MavenContext(path, parser.groupId(), parser.artifactId(), null, new File().setBase("maven-metadata").setType(result.ext()).setHash(result.hashExt()));
|
||||
}
|
||||
}
|
||||
throw new RuntimeException();
|
||||
|
||||
@ -31,7 +31,7 @@ public class PomService
|
||||
version.setUploadedBy(securityIdentity.getPrincipal().getName());
|
||||
if (version.getPom() == null)
|
||||
{
|
||||
version.setPom(new Pom().setPom(new String(body)).setMd5(md5).setSha1(sha1).setVersion(version).setUrl(mavenContext.path()).setFilename(mavenContext.file().getRaw()));
|
||||
version.setPom(new Pom().setPom(new String(body)).setMd5(md5).setSha1(sha1).setVersion(version).setUrl(mavenContext.path()).setFileBase(mavenContext.file().getBase()));
|
||||
versionService.persist(version);
|
||||
return Response.status(Response.Status.CREATED).build();
|
||||
}
|
||||
|
||||
@ -72,7 +72,7 @@ create table version
|
||||
|
||||
create table jar
|
||||
(
|
||||
filename varchar(255),
|
||||
file_base varchar(255),
|
||||
id varchar(255) not null
|
||||
primary key,
|
||||
md5 varchar(255),
|
||||
@ -86,7 +86,7 @@ create table jar
|
||||
|
||||
create table pom
|
||||
(
|
||||
filename varchar(255),
|
||||
file_base varchar(255),
|
||||
id varchar(255) not null
|
||||
primary key,
|
||||
md5 varchar(255),
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user