From 02d9d30985f96a2d4b65e2486b6ed23c991ba5ea Mon Sep 17 00:00:00 2001 From: Benjamin Date: Sat, 12 Mar 2022 11:19:34 +0100 Subject: [PATCH] =?UTF-8?q?D=C3=A9but=20ajout=20chemin=20de=20sauvegarde?= =?UTF-8?q?=20dans=20la=20configuration=20de=20l'application?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/lightcontainer/App.java | 2 +- .../protocol/rules/reader/SavefileRule.java | 6 ++++-- app/src/main/java/lightcontainer/storage/Repository.java | 8 ++++++++ app/src/main/resources/appdata.json | 1 + 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/lightcontainer/App.java b/app/src/main/java/lightcontainer/App.java index 88d4ae3..c951d96 100644 --- a/app/src/main/java/lightcontainer/App.java +++ b/app/src/main/java/lightcontainer/App.java @@ -37,7 +37,7 @@ public class App { protocolRep.addReader(new SignupRule(protocolRep)); protocolRep.addReader(new SignoutRule()); protocolRep.addReader(new FilelistRule(protocolRep)); - protocolRep.addReader(new SavefileRule(protocolRep)); + protocolRep.addReader(new SavefileRule(protocolRep, repositoryStorage.getStoragePath())); protocolRep.addReader(new SendOkRule(protocolRep)); protocolRep.addWriter(new SignOkRule()); diff --git a/app/src/main/java/lightcontainer/protocol/rules/reader/SavefileRule.java b/app/src/main/java/lightcontainer/protocol/rules/reader/SavefileRule.java index 5f1bfa8..90d95c9 100644 --- a/app/src/main/java/lightcontainer/protocol/rules/reader/SavefileRule.java +++ b/app/src/main/java/lightcontainer/protocol/rules/reader/SavefileRule.java @@ -27,11 +27,13 @@ public class SavefileRule extends ProtocolReader { private static final int FILE_SIZE = 1; // Index file size. private ProtocolRepository protocolRep; + private String storagePath; // Constructor - public SavefileRule(ProtocolRepository protocolRep) { + public SavefileRule(ProtocolRepository protocolRep, String storagePath) { super(NAME, PATTERN); this.protocolRep = protocolRep; + this.storagePath = storagePath; } public class Result extends ProtocolResult { @@ -52,7 +54,7 @@ public class SavefileRule extends ProtocolReader { System.out.printf("Sauvegarde du fichier : %s %d\n", filename, size); try { - FileReceiver fileReceiver = new FileReceiver("D:\\"); //"/home/benjamin/ffe"); + FileReceiver fileReceiver = new FileReceiver(storagePath); // "D:\\"); //"/home/benjamin/ffe"); String key = AES_GCM.generateSecretKey(); String iv = AES_GCM.generateIV(); diff --git a/app/src/main/java/lightcontainer/storage/Repository.java b/app/src/main/java/lightcontainer/storage/Repository.java index ecf6579..bb8b6da 100644 --- a/app/src/main/java/lightcontainer/storage/Repository.java +++ b/app/src/main/java/lightcontainer/storage/Repository.java @@ -114,4 +114,12 @@ public class Repository { public String getUserPasswordSalt(String login) { return appData.getUserPasswordSalt(login); } + + /** + * Méthode permettant de récupérer le chemin de sauvegarde des fichiers + * @return + */ + public String getStoragePath() { + return null; + } } diff --git a/app/src/main/resources/appdata.json b/app/src/main/resources/appdata.json index 67faaa8..4a9ff14 100644 --- a/app/src/main/resources/appdata.json +++ b/app/src/main/resources/appdata.json @@ -4,6 +4,7 @@ "multicast_port": 15502, "network_interface": "My network interface", "tls": true, + "storagePath": "/home/benjamin/ffe", "users": [ { "name": "benjamin",