Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
SR2-projet2-VANDEWAETER-DIAF
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Fabio Vandewaeter
SR2-projet2-VANDEWAETER-DIAF
Commits
9f58c8c7
Commit
9f58c8c7
authored
3 weeks ago
by
Fabio Vandewaeter
Browse files
Options
Downloads
Patches
Plain Diff
fix sync sous dossiers
parent
88617231
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/fil/sr2/projet2/FlopBoxClient.java
+1
-130
1 addition, 130 deletions
src/main/java/fil/sr2/projet2/FlopBoxClient.java
with
1 addition
and
130 deletions
src/main/java/fil/sr2/projet2/FlopBoxClient.java
+
1
−
130
View file @
9f58c8c7
...
...
@@ -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
();
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment