Skip to content

Commit 8464abb

Browse files
committed
Back up updates to configured data locations, fix issues
This gives us baseline and update files in the same directory. To create a new, up-to-date index, we just need to set up a new index name in the conf file and start the service. See #146
1 parent 2a02616 commit 8464abb

File tree

4 files changed

+10
-7
lines changed

4 files changed

+10
-7
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ bin
1111
*.jsonl
1212
*log*.gz
1313
*.tmp
14+
GND-updates*

app/apps/ConvertBaseline.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public static void main(String[] args) {
3939
new File(config("index.delete")).delete();
4040
for (String file : input) {
4141
FileOpener opener = new FileOpener();
42-
File out = new File(outFile, new File(file).getName() + ".jsonl");
42+
File out = outFile.isDirectory() ? new File(outFile, new File(file).getName() + ".jsonl") : outFile;
4343
final ObjectWriter<String> writer = new ObjectWriter<>(out.getAbsolutePath());
4444
opener//
4545
.setReceiver(new XmlDecoder())//

app/apps/ConvertUpdates.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,11 @@ public class ConvertUpdates {
3333
public static void main(String[] args) throws IOException {
3434
if (args.length == 1 || args.length == 2) {
3535
Pair<String, String> startAndEnd = getUpdates(args[0], args.length == 2 ? args[1] : null);
36-
backup(new File(config("data.updates.rdf")), startAndEnd.getLeft(), startAndEnd.getRight());
36+
String start = startAndEnd.getLeft();
37+
String end = startAndEnd.getRight();
38+
backup(new File(config("data.updates.rdf")), new File(config("data.rdfxml")), start, end);
3739
ConvertBaseline.main(new String[] { config("data.updates.rdf"), config("data.updates.data") });
38-
backup(new File(config("data.updates.data")), startAndEnd.getLeft(), startAndEnd.getRight());
40+
backup(new File(config("data.updates.data")), new File(config("data.jsonlines")), start, end);
3941
} else {
4042
System.err.println(
4143
"Pass either one argument, the start date for getting updates, or two, the start and the end date.");
@@ -120,10 +122,10 @@ private static void writeLastSuccessfulUpdate(String until) {
120122
}
121123
}
122124

123-
private static void backup(File source, String start, String end) throws IOException {
125+
private static void backup(File source, File folder, String start, String end) throws IOException {
124126
String name = source.getName();
125-
File target = new File(source.getParentFile(), String.format("%s_%s_%s%s",
126-
name.substring(0, name.lastIndexOf('.')), start, end, name.substring(name.lastIndexOf('.'))));
127+
File target = new File(folder, String.format("%s_%s_%s%s", name.substring(0, name.lastIndexOf('.')), start, end,
128+
name.substring(name.lastIndexOf('.'))));
127129
Files.copy(source.toPath(), target.toPath(), StandardCopyOption.REPLACE_EXISTING);
128130
}
129131

test/apps/ConvertTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public class ConvertTest {
5050
@Parameters(name = "{0}")
5151
public static Collection<Object[]> data() {
5252
return Arrays.asList(new Object[][] { //
53-
{ "test/data/GND.rdf", "test/data" }, //
53+
{ "test/data/GND.rdf", "test/data/GND.jsonl" }, //
5454
{ "test/data/input", "test/data/index" } });
5555
}
5656

0 commit comments

Comments
 (0)