closed #304,#33,#302,#307,#301,#305
This commit is contained in:
Generated
+9
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectCodeStyleSettingsManager">
|
||||
<option name="PER_PROJECT_SETTINGS">
|
||||
<value />
|
||||
</option>
|
||||
<option name="PREFERRED_PROJECT_CODE_STYLE" value="Default (1)" />
|
||||
</component>
|
||||
</project>
|
||||
@@ -3,7 +3,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>de.selfomat</groupId>
|
||||
<artifactId>selfomat-single-user</artifactId>
|
||||
<version>0.4.0.11-SNAPSHOT</version>
|
||||
<version>0.4.0.13-SNAPSHOT</version>
|
||||
|
||||
<scm>
|
||||
<url>scm:svn:svn://simongehrig:L4ut5pr3ch3r!@svn.picture.tools/selfomat/trunk/selfomat-java-single-user</url>
|
||||
|
||||
@@ -204,7 +204,7 @@ public class CaptureCtl {
|
||||
Platform.runLater(new Runnable() {
|
||||
public void run() {
|
||||
// Set Countdown Text
|
||||
countdownText.setText(String.valueOf(counter + 1));
|
||||
countdownText.setText(String.valueOf(counter + 2));
|
||||
// Set the Counter Visible
|
||||
countdownText.setVisible(true);
|
||||
}
|
||||
|
||||
@@ -119,8 +119,8 @@ public class SOMGUI extends Application {
|
||||
|
||||
// Set the Upload scene
|
||||
changetoupload();
|
||||
// Start Upload Process
|
||||
|
||||
// Start Upload Process (switches over to Picture afterwards)
|
||||
FilesWorker.upload();
|
||||
// Set the Picture scene
|
||||
}
|
||||
}
|
||||
@@ -31,7 +31,7 @@ public class SOMConfig {
|
||||
public static final int SERIES_COUNTER = 4;
|
||||
// Seconds before image is taken
|
||||
@XmlElement(name = "COUNTDOWN_COUNTER")
|
||||
public static final int COUNTDOWN_COUNTER = 3;
|
||||
public static final int COUNTDOWN_COUNTER = 4;
|
||||
// Images per Page in the Gallery
|
||||
public static final int IMAGES_PER_PAGE = 9;
|
||||
// Limot of Parallel Uploads
|
||||
|
||||
@@ -61,7 +61,7 @@ public class SOMEvent {
|
||||
*/
|
||||
public void getEventImages() {
|
||||
// Behandelt
|
||||
if (!imagesread) {
|
||||
// if (!imagesread) {
|
||||
|
||||
File[] files = FilesWorker.getSourcePath().listFiles();
|
||||
|
||||
@@ -74,8 +74,8 @@ public class SOMEvent {
|
||||
this.addImage(img);
|
||||
}
|
||||
|
||||
imagesread = true;
|
||||
}
|
||||
// imagesread = true;
|
||||
// }
|
||||
// return;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,14 +2,15 @@ package model;
|
||||
|
||||
import workers.FilesWorker;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.io.File;
|
||||
import java.nio.file.Files;
|
||||
|
||||
public class SOMImage {
|
||||
|
||||
private static String name; // the filename
|
||||
|
||||
private final SOMConfig config = SOMConfig.getInstance();
|
||||
|
||||
private final File tmb; // thumbnail
|
||||
private final File prv; // preview
|
||||
private final File src; // source
|
||||
@@ -25,8 +26,7 @@ public class SOMImage {
|
||||
|
||||
File src = new File(FilesWorker.getSourcePath().toString() + "/" + name);
|
||||
|
||||
File prv = new File(FilesWorker.getPreviewPath().toString() + "/"
|
||||
+ name);
|
||||
File prv = new File(FilesWorker.getPreviewPath().toString() + "/" + name);
|
||||
|
||||
File tmb = new File(FilesWorker.getThumbPath().toString() + "/" + name);
|
||||
|
||||
@@ -153,23 +153,23 @@ public class SOMImage {
|
||||
* @param type 0 = thumb, 1 = preview, 2 = full Size
|
||||
* @return
|
||||
*/
|
||||
public ImageIcon toImageIcon(int type) {
|
||||
File imagepath;
|
||||
switch (type) {
|
||||
case 0:
|
||||
imagepath = getTmb();
|
||||
break;
|
||||
case 1:
|
||||
imagepath = getPrv();
|
||||
break;
|
||||
case 2:
|
||||
imagepath = getSrc();
|
||||
break;
|
||||
default:
|
||||
imagepath = null;
|
||||
break;
|
||||
}
|
||||
|
||||
return new ImageIcon(imagepath.getPath());
|
||||
}
|
||||
// public ImageIcon toImageIcon(int type) {
|
||||
// File imagepath;
|
||||
// switch (type) {
|
||||
// case 0:
|
||||
// imagepath = getTmb();
|
||||
// break;
|
||||
// case 1:
|
||||
// imagepath = getPrv();
|
||||
// break;
|
||||
// case 2:
|
||||
// imagepath = getSrc();
|
||||
// break;
|
||||
// default:
|
||||
// imagepath = null;
|
||||
// break;
|
||||
// }
|
||||
//
|
||||
// return new ImageIcon(imagepath.getPath());
|
||||
// }
|
||||
}
|
||||
|
||||
@@ -131,14 +131,13 @@ public class FilesWorker {
|
||||
public static void upload() {
|
||||
try {
|
||||
|
||||
// Backup the Backup
|
||||
|
||||
|
||||
// Get all Files in the image Folder
|
||||
List<File> images = allFilesForUpload();
|
||||
|
||||
// Lists for either dirs or pictures
|
||||
List<File> dirs = new ArrayList<File>();
|
||||
List<File> pics = new ArrayList<File>();
|
||||
List<File> remv = new ArrayList<File>();
|
||||
|
||||
// Check for internet connection
|
||||
if (internet()) {
|
||||
@@ -150,6 +149,7 @@ public class FilesWorker {
|
||||
String currentdir = "";
|
||||
|
||||
for (String split : splits) {
|
||||
|
||||
currentdir = currentdir + "/" + split;
|
||||
dirs.add(new File(currentdir));
|
||||
|
||||
@@ -168,6 +168,8 @@ public class FilesWorker {
|
||||
if (file.isFile()
|
||||
&& file.toString().contains("src")) {
|
||||
pics.add(file);
|
||||
} else {
|
||||
remv.add(file);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -178,9 +180,6 @@ public class FilesWorker {
|
||||
int queueddirs = 0;
|
||||
int queuedfiles = 0;
|
||||
|
||||
// GET THE UI
|
||||
SOMGUI.changetoupload();
|
||||
|
||||
// UPLOAD DIRECTORIES
|
||||
List<File> limitdirs = new ArrayList<File>();
|
||||
|
||||
@@ -221,9 +220,25 @@ public class FilesWorker {
|
||||
|
||||
System.out.println("Clear File Queue");
|
||||
limitpics.clear();
|
||||
} else if (queuedfiles == pics.size() && pics.size() != 0) {
|
||||
// reboot
|
||||
new ProcessBuilder("reboot").start();
|
||||
}
|
||||
}
|
||||
|
||||
// Remove the rest of the files (thumbs, previews)
|
||||
for (File rem : remv) {
|
||||
if (rem.isFile()) {
|
||||
rem.delete();
|
||||
}
|
||||
}
|
||||
|
||||
// Archive the Backup
|
||||
archiveBackup();
|
||||
|
||||
// Update the State fot previews and thumbs
|
||||
SOMEvent.getInstance().getImages();
|
||||
|
||||
SOMGUI.changetopicture();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
@@ -235,6 +250,42 @@ public class FilesWorker {
|
||||
}
|
||||
}
|
||||
|
||||
private static void archiveBackup() {
|
||||
Task<Boolean> task = new Task<Boolean>() {
|
||||
|
||||
@Override
|
||||
protected Boolean call() throws Exception {
|
||||
// build the archive process
|
||||
// TODO remove -k option (this option skips certificate verification)
|
||||
// TODO Make Software run in SELFOMAT Directory
|
||||
ProcessBuilder builder = new ProcessBuilder(
|
||||
"bash",
|
||||
"SELFOMAT/sh/move-backup.sh"
|
||||
);
|
||||
|
||||
// make the process traceable
|
||||
builder.redirectErrorStream(true);
|
||||
// launch archive process
|
||||
Process process = builder.start();
|
||||
|
||||
// wait for the process to end
|
||||
if (process.waitFor() == 0) {
|
||||
// process ended successful
|
||||
System.out.println("archiving Backup");
|
||||
|
||||
return true;
|
||||
|
||||
} else {
|
||||
// process ended failing
|
||||
// TODO Catch failed uploads
|
||||
|
||||
System.out.println("Backup archiving failed!");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private static void uploadFile(final List<File> files) throws Exception {
|
||||
final Thread[] threads = new Thread[files.size()];
|
||||
|
||||
@@ -325,8 +376,7 @@ public class FilesWorker {
|
||||
SOMConfig.CLOUD_CREDENTIALS,
|
||||
"-X",
|
||||
"MKCOL",
|
||||
SOMConfig.CLOUD_ADDRESS + SOMConfig.getEventPicDir(),
|
||||
// dir.toString().replace("/src", ""),
|
||||
SOMConfig.CLOUD_ADDRESS + dir.toString().replace("/src", ""),
|
||||
"-k");
|
||||
|
||||
// make the process traceable
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
#!/usr/bin/env bash
|
||||
# get the current Time
|
||||
STAMP=$(date "+%Y%m%d-%H%M%S")
|
||||
# make the dir to move to
|
||||
mkdir img.backup/${STAMP}/
|
||||
# move the files
|
||||
mv img.backup/images/src/* img.backup/${STAMP}/
|
||||
@@ -29,7 +29,7 @@ if [ "$1" == "-h" ];
|
||||
# get the local images' MD5
|
||||
pre_local_md5=$(md5sum "$1" | awk '{print $1}')
|
||||
|
||||
# compare both MD5s
|
||||
# compare both MD5s manually (for development)
|
||||
echo "$pre_online_md5"
|
||||
echo "$pre_local_md5"
|
||||
|
||||
@@ -63,7 +63,7 @@ if [ "$1" == "-h" ];
|
||||
# get the local images' MD5
|
||||
local_md5=$(md5sum "$1" | awk '{print $1}')
|
||||
|
||||
# compare both MD5s
|
||||
# compare both MD5s manually (for development)
|
||||
echo "$online_md5"
|
||||
echo "$local_md5"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user