diff --git a/CEO/backupSchemes.json b/CEO/backupSchemes.json new file mode 100644 index 0000000..b9cbe93 --- /dev/null +++ b/CEO/backupSchemes.json @@ -0,0 +1,12 @@ +{ + "7c0ef9d5-23ed-47a6-bfb4-fdcfce436904": { + "ip": "192.168.169.19", + "directoryStructure": "{\"backup_dir\":{\"files\":[],\"fisiere\":{\"files\":[\"New Microsoft Excel Worksheet.xlsx\",\"New Microsoft Word Document.docx\"]}}}", + "totalSize": 19363 + }, + "59c712d9-e6dd-438f-aec9-31ca2ae750e6": { + "ip": "192.168.169.53", + "directoryStructure": "{\"backup_dir\":{\"files\":[],\"fisiere\":{\"files\":[\"New Microsoft Excel Worksheet.xlsx\",\"New Microsoft Word Document.docx\"]}}}", + "totalSize": 19363 + } +} \ No newline at end of file diff --git a/CEO/backup_directories/59c712d9-e6dd-438f-aec9-31ca2ae750e6/backup_dir/fisiere/New Microsoft Excel Worksheet.xlsx b/CEO/backup_directories/59c712d9-e6dd-438f-aec9-31ca2ae750e6/backup_dir/fisiere/New Microsoft Excel Worksheet.xlsx new file mode 100644 index 0000000..d8b87bb Binary files /dev/null and b/CEO/backup_directories/59c712d9-e6dd-438f-aec9-31ca2ae750e6/backup_dir/fisiere/New Microsoft Excel Worksheet.xlsx differ diff --git a/CEO/backup_directories/59c712d9-e6dd-438f-aec9-31ca2ae750e6/backup_dir/fisiere/New Microsoft Word Document.docx b/CEO/backup_directories/59c712d9-e6dd-438f-aec9-31ca2ae750e6/backup_dir/fisiere/New Microsoft Word Document.docx new file mode 100644 index 0000000..ff94689 Binary files /dev/null and b/CEO/backup_directories/59c712d9-e6dd-438f-aec9-31ca2ae750e6/backup_dir/fisiere/New Microsoft Word Document.docx differ diff --git a/CEO/dirBackup.json b/CEO/dirBackup.json new file mode 100644 index 0000000..a1c8356 --- /dev/null +++ b/CEO/dirBackup.json @@ -0,0 +1,15 @@ +{ + "path": "/home/andrei/Desktop/proiect-licenta/dirs/ceo/backup_dir", + "structure": { + "backup_dir": { + "files": [], + "fisiere": { + "files": [ + "New Microsoft Excel Worksheet.xlsx", + "New Microsoft Word Document.docx" + ] + } + } + }, + "size": 19363 +} \ No newline at end of file diff --git a/CEO/dirShare.json b/CEO/dirShare.json new file mode 100644 index 0000000..f07ccf8 --- /dev/null +++ b/CEO/dirShare.json @@ -0,0 +1,3 @@ +{ + "path": "/home/andrei/Desktop/proiect-licenta/dirs/ceo/share_dir" +} \ No newline at end of file diff --git a/CEO/ipConfig.json b/CEO/ipConfig.json new file mode 100644 index 0000000..a02bae5 --- /dev/null +++ b/CEO/ipConfig.json @@ -0,0 +1 @@ +b=Êxмâðgi”ÃT§ì cQÁ,|‚Â{u«ê \ No newline at end of file diff --git a/CEO/loginData.json b/CEO/loginData.json new file mode 100644 index 0000000..c3ada37 Binary files /dev/null and b/CEO/loginData.json differ diff --git a/CEO/src/renderer/js/sending_file_confirmation.js b/CEO/src/renderer/js/sending_file_confirmation.js index a67265a..9fe8f75 100644 --- a/CEO/src/renderer/js/sending_file_confirmation.js +++ b/CEO/src/renderer/js/sending_file_confirmation.js @@ -6,40 +6,29 @@ document.addEventListener("DOMContentLoaded", async function () { const uploadPromises = uploadData.users.map(async (user) => { try { - const response = await fetch(uploadData.filePath); - if (!response.ok) { - throw new Error('Failed to fetch file'); - } - const file = await response.blob(); - if (!file.size) { - throw new Error('File is empty or could not be loaded'); + const fileResponse = await fetch(uploadData.filePath); + if (!fileResponse.ok) { + throw new Error(`HTTP error when trying to fetch the file: status ${fileResponse.statusText}`); } + const fileBlob = await fileResponse.blob(); - const formData = new FormData(); - formData.append('file', file); - formData.append('idUser', user.userId); - formData.append('nameOfFile', user.fileName); - formData.append('sizeOfFile', file.size); + await timeout(5000); // Timeout to simulate delay or wait + const url = `http://${user.destIp}:${user.destPort}/share_file`; - // Debugging FormData content - for (let [key, value] of formData.entries()) { - console.log(key, value instanceof Blob ? `Blob (${value.size} bytes)` : value); - } - - const url = `http://${user.destIp}:${user.destPort}/upload`; const uploadResponse = await fetch(url, { method: 'POST', - body: formData + headers: { + 'Content-Type': 'application/octet-stream', + 'X-IdUser': user.userId, + 'X-NameOfFile': user.fileName, + 'X-SizeOfFile': fileBlob.size + }, + body: fileBlob }); if (!uploadResponse.ok) { - try { - const errorResponse = await uploadResponse.json(); - throw new Error(`HTTP error during file upload to ${user.userId}: ${errorResponse.message}`); - } catch (parseError) { - const responseText = await uploadResponse.text(); - throw new Error(`HTTP error during file upload to ${user.userId}: ${responseText}`); - } + const response = await uploadResponse.json(); + throw new Error(`HTTP error during file upload to ${user.userId}: status ${response.message}`); } return {userId: user.userId, success: true, message: `Upload successful for user ${user.userId}`}; @@ -51,7 +40,11 @@ document.addEventListener("DOMContentLoaded", async function () { const results = await Promise.all(uploadPromises); results.forEach(result => { - console.log(result.message); + if (result.success) { + console.log(result.message); + } else { + console.error(result.message); + } }); console.log('All files processed. Check the console for detailed results.'); } catch (error) { @@ -66,6 +59,7 @@ document.addEventListener("DOMContentLoaded", async function () { } await performUploads(); - await timeout(3000); // Consider the necessity of this delay in production - fadeOut('main_menu.html'); + await timeout(3000); + fadeOut('main_menu.html'); // Make sure this function is properly defined or available in your context }); + diff --git a/CEO/usersInSystem.json b/CEO/usersInSystem.json new file mode 100644 index 0000000..9069ec4 Binary files /dev/null and b/CEO/usersInSystem.json differ diff --git a/UC/backend/src/db/backup_schemes.json b/UC/backend/src/db/backup_schemes.json index 0bbe8e8..b9cbe93 100644 --- a/UC/backend/src/db/backup_schemes.json +++ b/UC/backend/src/db/backup_schemes.json @@ -1,11 +1,11 @@ { "7c0ef9d5-23ed-47a6-bfb4-fdcfce436904": { - "ip": "192.168.0.195", + "ip": "192.168.169.19", "directoryStructure": "{\"backup_dir\":{\"files\":[],\"fisiere\":{\"files\":[\"New Microsoft Excel Worksheet.xlsx\",\"New Microsoft Word Document.docx\"]}}}", "totalSize": 19363 }, "59c712d9-e6dd-438f-aec9-31ca2ae750e6": { - "ip": "192.168.0.18", + "ip": "192.168.169.53", "directoryStructure": "{\"backup_dir\":{\"files\":[],\"fisiere\":{\"files\":[\"New Microsoft Excel Worksheet.xlsx\",\"New Microsoft Word Document.docx\"]}}}", "totalSize": 19363 }