Currently, I am facing a challenge that I need assistance with. I am working on an updater that retrieves an XML list of files from a CDN and compares it with an older list to identify any file differences. The objective is to determine which files are out of date and require re-downloading. Unfortunately, I have not been able to find a suitable solution for this issue.
In my current setup, I am using three arrays: Array1, Array2, and DiffArray. Array1 contains the XML entries from the CDN, which can be considered as the master list. Array2 stores the old entries of the files we currently possess, acting as the slave list. Array3 is utilized to store the differences between the two arrays.
Here is a glimpse of the information present in each array. Each new line represents a separate index in the corresponding array:
Array1:
cbt/ar/816.mp3
2019-06-05T16:40:33.212Z
cbt/ar/817.mp3
2019-06-05T16:40:31.509Z
cbt/ar/818.mp3
2019-04-05T16:40:30.978Z
cbt/ar/819.mp3
2019-04-05T16:40:29.807Z
Array2:
cbt/ar/816.mp3
2019-04-05T16:40:33.212Z
cbt/ar/817.mp3
2019-04-05T16:40:31.509Z
cbt/ar/818.mp3
2019-04-05T16:40:30.978Z
cbt/ar/819.mp3
2019-04-05T16:40:29.807Z
A couple of points to note: 1.) This list consists of file names along with their last modified dates. 2.) Array1 includes newer versions of 816.mp3 and 817.mp3 files.
The goal is to compare the file versions, identify the discrepancies, and proceed to download the updated files.
The current code snippet I am using is as follows, but it does not effectively address the issue:
var a = [];
for (var x = 0; x < remoteArray.length; x++) {
a[remoteArray[x]] = true;
}
for (var y = 0; y < localArray.length; y++) {
if (a[localArray[y]]) {
delete a[localArray[y]];
} else {
a[localArray[y]] = true;
}
}
for (var z in a) {
diffArray.push(z);
log.info("::DIFFERENCES::" + z);
}
This code snippet only displays the literal differences and does not provide a clear indication of which files require updating.