updated htmlutils external
added temporary file generation when uploading a new package
This commit is contained in:
@@ -33,6 +33,8 @@ import java.util.*;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import static java.nio.file.StandardCopyOption.ATOMIC_MOVE;
|
||||
|
||||
@XmlRootElement
|
||||
class PkgTuple
|
||||
{
|
||||
@@ -306,7 +308,7 @@ public class PacmanWebService
|
||||
if (filename == null)
|
||||
throw new BadRequestException();
|
||||
|
||||
File file = new File(ctx.getRepoFolder(), filename);
|
||||
File file = File.createTempFile(filename, "tmp", new File(ctx.getRepoFolder()));
|
||||
|
||||
TypedQuery<PkgData> fquery = em.createQuery(fileNameQuery, PkgData.class);
|
||||
fquery.setParameter("fileName", filename);
|
||||
@@ -332,6 +334,7 @@ public class PacmanWebService
|
||||
|
||||
ut.begin();
|
||||
PkgData pkg = Parser.parseFile(file);
|
||||
pkg.fileName = filename;
|
||||
|
||||
TypedQuery<PkgName> nquery = em.createQuery(nameQuery, PkgName.class);
|
||||
nquery.setParameter("name", pkg.name.id);
|
||||
@@ -345,6 +348,7 @@ public class PacmanWebService
|
||||
log.log(Level.INFO, String.format("Persisting package %s", pkg.fileName));
|
||||
URI pkgUri = uriInfo.getAbsolutePathBuilder().path(pkg.fileName).build();
|
||||
ut.commit();
|
||||
Files.move(file.toPath(), new File(ctx.getRepoFolder(), filename).toPath(), ATOMIC_MOVE);
|
||||
ctx.invalidateCache = true;
|
||||
cachedMap = null;
|
||||
return Response.created(pkgUri).build();
|
||||
|
Reference in New Issue
Block a user