Skip to content
Snippets Groups Projects
Commit 9f58c8c7 authored by Fabio Vandewaeter's avatar Fabio Vandewaeter
Browse files

fix sync sous dossiers

parent 88617231
Branches
Tags
No related merge requests found
......@@ -235,52 +235,6 @@ public class FlopBoxClient {
*/
public void importFiles(String alias, String remotePath, JsonNode tree, Path localDir)
throws IOException, InterruptedException {
/*
* if (!filesMetadata.containsKey(alias)) {
* filesMetadata.put(alias, new HashMap<>());
* }
*
* // Traitement des dossiers
* if (tree.has("children") && tree.get("children").isArray()) {
* for (JsonNode dir : tree.get("children")) {
* String dirName = dir.get("name").asText();
* String newRemotePath = remotePath.isEmpty() ? dirName : remotePath + "/" +
* dirName;
* Path newLocalDir = localDir.resolve(dirName);
*
* Files.createDirectories(newLocalDir);
*
* // Récupération récursive du contenu du dossier
* JsonNode subTree = fetchFtpTree(alias, newRemotePath);
* importFiles(alias, newRemotePath, subTree, newLocalDir);
* }
* }
*
* // Traitement des fichiers
* if (tree.has("files") && tree.get("files").isArray()) {
* for (JsonNode file : tree.get("files")) {
* String fileName = file.get("name").asText();
* String fileRemotePath = remotePath.isEmpty() ? fileName : remotePath + "/" +
* fileName;
* Path localFile = localDir.resolve(fileName);
*
* // Skip .deleted directory files at root level
* if (fileRemotePath.startsWith(".deleted/")) {
* continue;
* }
*
* // Téléchargement du fichier
* downloadFile(alias, fileRemotePath, localFile);
*
* // Stockage des métadonnées
* long fileSize = Files.size(localFile);
* long lastModified = Files.getLastModifiedTime(localFile).toMillis();
*
* FileInfo fileInfo = new FileInfo(fileRemotePath, fileSize, lastModified);
* filesMetadata.get(alias).put(fileRemotePath, fileInfo);
* }
* }
*/
if (!filesMetadata.containsKey(alias)) {
filesMetadata.put(alias, new HashMap<>());
}
......@@ -473,89 +427,6 @@ public class FlopBoxClient {
* @throws InterruptedException En cas d'interruption lors de la vérification
*/
public void checkRemoteChanges(String alias, String remotePath) throws IOException, InterruptedException {
/*
* JsonNode tree = fetchFtpTree(alias, remotePath);
* Path localDir = syncDirectory.resolve(alias);
*
* if (!remotePath.isEmpty()) {
* localDir = localDir.resolve(remotePath);
* }
*
* // Traitement des dossiers
* if (tree.has("children") && tree.get("children").isArray()) {
* for (JsonNode dir : tree.get("children")) {
* String dirName = dir.get("name").asText();
*
* // Skip .deleted directory
* if (dirName.equals(".deleted") && remotePath.isEmpty()) {
* continue;
* }
*
* String newRemotePath = remotePath.isEmpty() ? dirName : remotePath + "/" +
* dirName;
* Path newLocalDir = localDir.resolve(dirName);
*
* Files.createDirectories(newLocalDir);
*
* // Récursion pour les sous-répertoires
* checkRemoteChanges(alias, newRemotePath);
* }
* }
*
* // Traitement des fichiers
* if (tree.has("files") && tree.get("files").isArray()) {
* for (JsonNode file : tree.get("files")) {
* String fileName = file.get("name").asText();
* String fileRemotePath = remotePath.isEmpty() ? fileName : remotePath + "/" +
* fileName;
* Path localFile = localDir.resolve(fileName);
*
* long remoteSize = file.get("size").asLong();
* long remoteModified = 0;
*
* if (file.has("timestamp")) {
* remoteModified = file.get("timestamp").asLong();
* }
*
* Map<String, FileInfo> aliasMetadata = filesMetadata.getOrDefault(alias, new
* HashMap<>());
* FileInfo storedInfo = aliasMetadata.get(fileRemotePath);
*
* boolean needDownload = false;
*
* if (!Files.exists(localFile)) {
* // Fichier distant non présent localement
* needDownload = true;
* } else if (storedInfo == null) {
* // Pas d'information stockée pour ce fichier
* needDownload = true;
* } else if (remoteModified > 0 && remoteModified > storedInfo.lastModified) {
* // Fichier distant plus récent
* needDownload = true;
* } else if (remoteSize != storedInfo.size) {
* // Taille différente
* needDownload = true;
* }
*
* if (needDownload) {
* downloadFile(alias, fileRemotePath, localFile);
*
* // Mise à jour des métadonnées
* long actualSize = Files.size(localFile);
* long actualLastModified = Files.getLastModifiedTime(localFile).toMillis();
*
* if (!aliasMetadata.containsKey(fileRemotePath)) {
* aliasMetadata.put(fileRemotePath, new FileInfo(fileRemotePath, actualSize,
* actualLastModified));
* } else {
* storedInfo.size = actualSize;
* storedInfo.lastModified = actualLastModified;
* }
* }
* }
* }
*/
JsonNode tree = fetchFtpTree(alias, remotePath);
Path localDir = syncDirectory.resolve(alias);
......@@ -591,7 +462,7 @@ public class FlopBoxClient {
if (child.has("size") && !child.get("size").isNull()) {
remoteSize = child.get("size").asLong();
}
System.out.println("ICICICICICI" + child);
if (child.has("timestamp") && !child.get("timestamp").isNull()) {
remoteModified = child.get("timestamp").asLong();
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment