chg: don’t save site export as antville file anymore

This commit is contained in:
Tobi Schäfer 2018-05-20 08:52:07 +02:00
parent 704f80de75
commit 4c85e79dec
2 changed files with 13 additions and 30 deletions

View file

@ -105,26 +105,17 @@ global.Exporter = (function() {
Exporter.saveSite = function(site, user) {
const sql = new Sql();
const zip = new helma.Zip();
const dirName = app.appsProperties['static'] + '/export';
const fileName = 'antville-site-' + java.util.UUID.randomUUID() + '.zip';
const file = new java.io.File(dirName, fileName);
if (site.export) {
const archive = new java.io.File(dirName, site.export.split('/').pop());
if (archive.exists()) archive['delete']();
}
try {
if (site.export) {
let file = File.getById(site.export);
if (file) File.remove.call(file);
}
const index = {
comments: [],
files: [],
images: [],
members: [],
polls: [],
sites: [],
skins: [],
stories: [],
tags: []
};
const dir = new java.io.File(java.nio.file.Files.createTempDirectory(site.name));
const skinWriter = getJsonWriter(dir, 'skins.json');
let writer = getJsonWriter(dir, 'index.json');
@ -155,7 +146,6 @@ global.Exporter = (function() {
sql.traverse(function() {
app.log('Exporting membership #' + this.creator_id);
//index.members.push(this);
writer.push(this);
});
@ -245,24 +235,17 @@ global.Exporter = (function() {
});
const xml = Exporter.getSiteXml(site);
zip.addData(xml, 'export.xml');
zip.add(dir);
zip.close();
zip.save(file);
const mime = {
file: new Packages.helma.util.MimePart(fileName, zip.getData(), 'application/zip'),
file_origin: site.href('export')
};
const file = File.add(mime, site, user);
site.export = file._id;
site.export = app.appsProperties.staticMountpoint + '/export/' + fileName;
site.job = null;
} catch (ex) {
app.log(ex.rhinoException);
}
// Reset the sites export status
site.job = null;
return;
};

View file

@ -1197,7 +1197,7 @@ a.gs-title:hover {
<% #export %>
<h1><% gettext "Export Site Data" %></h1>
<p>
<% if <% param.status %> is null then <% if <% site.export %> is null then '' else <% gettext "{0}Download the archive{1} or click “Export” to create a new one." <% file.href prefix="<a href='" suffix="'>" %> "</a>" %> %> else <% param.status %> %>
<% if <% param.status %> is null then <% if <% site.export %> is null then '' else <% gettext "{0}Download the archive{1} or click “Export” to create a new one." <% site.export prefix="<a href='" suffix="'>" %> "</a>" %> %> else <% param.status %> %>
</p>
<form action="<% site.href export %>" method="post">
<button type="submit" name="submit" value="<% if <% param.status %> is null then export else cancel %>" class='uk-button uk-button-primary'>