removed useless line from upload function
This commit is contained in:
@@ -1,12 +1,12 @@
|
||||
package org.jpacrepo.service;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.jpacrepo.context.ApplicationContext;
|
||||
import org.jpacrepo.context.*;
|
||||
import org.jpacrepo.context.DefaultConfiguration;
|
||||
import org.jpacrepo.model.HashList;
|
||||
import org.jpacrepo.model.PkgData;
|
||||
import org.jpacrepo.model.PkgList;
|
||||
import org.jpacrepo.model.PkgName;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.jpacrepo.pacbase.Parser;
|
||||
import org.jpacrepo.persistence.QueryEngine;
|
||||
|
||||
@@ -15,7 +15,6 @@ import javax.inject.Inject;
|
||||
import javax.persistence.*;
|
||||
import javax.ws.rs.*;
|
||||
import javax.ws.rs.core.*;
|
||||
import javax.ws.rs.core.Context;
|
||||
import java.io.*;
|
||||
import java.net.URI;
|
||||
import java.nio.file.Files;
|
||||
@@ -161,17 +160,6 @@ public class PacmanWebService
|
||||
throw new BadRequestException();
|
||||
|
||||
File file = new File(ctx.getRepoFolder(), filename);
|
||||
try
|
||||
{
|
||||
FileOutputStream fos = new FileOutputStream(file);
|
||||
IOUtils.copy(input, fos);
|
||||
fos.close();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Files.delete(file.toPath());
|
||||
throw e;
|
||||
}
|
||||
|
||||
TypedQuery<PkgData> fquery = em.createQuery(fileNameQuery, PkgData.class);
|
||||
fquery.setParameter("fileName", filename);
|
||||
@@ -179,16 +167,17 @@ public class PacmanWebService
|
||||
|
||||
if (savedFiles.size() > 0)
|
||||
{
|
||||
Files.delete(file.toPath());
|
||||
return Response.notModified().build();
|
||||
}
|
||||
else
|
||||
{
|
||||
PkgData pkg = serviceParser.parseFile(file);
|
||||
try
|
||||
{
|
||||
FileOutputStream fos = new FileOutputStream(file);
|
||||
IOUtils.copy(input, fos);
|
||||
fos.close();
|
||||
|
||||
TypedQuery<PkgData> hquery = em.createQuery(hashQuery, PkgData.class);
|
||||
hquery.setParameter("md5sum", pkg.md5sum);
|
||||
savedFiles = hquery.getResultList();
|
||||
PkgData pkg = serviceParser.parseFile(file);
|
||||
|
||||
TypedQuery<PkgName> nquery = em.createQuery(nameQuery, PkgName.class);
|
||||
nquery.setParameter("name", pkg.name.id);
|
||||
@@ -203,6 +192,12 @@ public class PacmanWebService
|
||||
URI pkgUri = uriInfo.getAbsolutePathBuilder().path(pkg.fileName).build();
|
||||
return Response.created(pkgUri).build();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Files.delete(file.toPath());
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Response manageQueryResult(List<PkgData> list)
|
||||
|
Reference in New Issue
Block a user