-
Notifications
You must be signed in to change notification settings - Fork 120
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Backup and restore working for Pro5 #1088
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -358,7 +358,135 @@ function install(steps) { | |||||
.catch(() => {}); // errors can be ignored here, since this is exclusively used for killing the promise chain | ||||||
} | ||||||
|
||||||
// AW : Return the total partition size of system+user | ||||||
function getUserSystemFileSize() { | ||||||
var fileSize = 0; | ||||||
return new Promise(function(resolve, reject) { | ||||||
adb | ||||||
.getState() | ||||||
.then(stdout => { | ||||||
var system = ""; | ||||||
var user = ""; | ||||||
if (stdout == "device") { | ||||||
system = "/userdata/system-data"; | ||||||
user = "/userdata/user-data"; | ||||||
} else { | ||||||
system = "/data/system-data"; | ||||||
user = "/data/user-data"; | ||||||
} | ||||||
adb | ||||||
.getFileSize(user) | ||||||
.then(stdout => { | ||||||
utils.log.debug("Returned userdata FileSize is " + stdout + " Ko"); | ||||||
fileSize = stdout; | ||||||
global.Backup.usersize = fileSize; | ||||||
adb | ||||||
.getFileSize(system) | ||||||
.then(stdout => { | ||||||
fileSize = fileSize + stdout; | ||||||
global.Backup.systemsize = stdout; | ||||||
utils.log.debug( | ||||||
"Returned systemdata FileSize is " + | ||||||
global.Backup.systemsize + | ||||||
" Ko" | ||||||
); | ||||||
utils.log.debug( | ||||||
"Returned Total FileSize is " + fileSize + " Ko" | ||||||
); | ||||||
global.Backup.TotalSize = fileSize; //resolve(fileSize) | ||||||
resolve(); | ||||||
}) | ||||||
.catch(reject); // system file size error | ||||||
}) | ||||||
.catch(reject); // user filesize error | ||||||
}) | ||||||
.catch(reject); // adb state error | ||||||
}); | ||||||
} | ||||||
|
||||||
// AW : Return the total used space for system+user data on Ubuntu os only | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
async function getDeviceUsedSpaceForBackup() { | ||||||
// Error to handle : No such file or directory | ||||||
// --output=used: No such file or directory | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is this? |
||||||
|
||||||
var res = await adb.shell("df -hBG / --output=used|tail -n1"); | ||||||
var res2 = await adb.shell("df -hBG /userdata --output=used|tail -n1"); | ||||||
res = parseFloat(res); | ||||||
res2 = parseFloat(res2); | ||||||
return res + res2; | ||||||
Comment on lines
+412
to
+416
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. make this one statement |
||||||
} | ||||||
|
||||||
// AW : Check if /data/user-data is present and mount it if not. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
function mountPartToBackup(device) { | ||||||
utils.log.info("mountPartToBackup"); | ||||||
return new Promise(function(resolve, reject) { | ||||||
var data_partition = ""; | ||||||
switch (device) { | ||||||
case "turbo": | ||||||
data_partition = "/dev/block/sda44"; | ||||||
break; | ||||||
default: | ||||||
data_partition = "/data"; | ||||||
break; | ||||||
} | ||||||
utils.log.info("device partition: " + data_partition); | ||||||
adb | ||||||
.shell("ls /data|grep system-data") | ||||||
.then(stdout => { | ||||||
utils.log.info("ls ok"); | ||||||
if (stdout) { | ||||||
resolve(); | ||||||
} else { | ||||||
utils.log.info("nothing found"); | ||||||
adb | ||||||
.shell("mount " + data_partition + " /data") | ||||||
.then(stdout => { | ||||||
utils.log.info("mounted"); | ||||||
resolve(); | ||||||
}) | ||||||
.catch(reject); // mount | ||||||
resolve(); | ||||||
} | ||||||
}) | ||||||
.catch(e => { | ||||||
adb | ||||||
.shell("mount " + data_partition + " /data") | ||||||
.then(stdout => { | ||||||
utils.log.info("Partition has been mounted"); | ||||||
resolve(); | ||||||
}) | ||||||
.catch(e => { | ||||||
reject("Unable to mount partition " + data_partition + " " + e); | ||||||
}); // mount | ||||||
//reject("Partition not mounted "+e); | ||||||
}); //ls | ||||||
Comment on lines
+460
to
+462
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove dead comments |
||||||
}); | ||||||
} | ||||||
|
||||||
// Check if we can restore the backup (checking available size) | ||||||
function isBackupRestorable(backup) { | ||||||
return adb | ||||||
.getTotalSize("/userdata") | ||||||
.then(tot => { | ||||||
utils.log.info( | ||||||
"Backup size:" + | ||||||
(backup.config.systemsize + backup.config.usersize) + | ||||||
", device size:" + | ||||||
tot | ||||||
); | ||||||
if (tot > backup.config.systemsize + backup.config.usersize) return true; | ||||||
else return false; | ||||||
}) | ||||||
.catch(err => { | ||||||
return false; | ||||||
}); | ||||||
} | ||||||
|
||||||
module.exports = { | ||||||
isBackupRestorable: isBackupRestorable, | ||||||
getDeviceUsedSpaceForBackup: getDeviceUsedSpaceForBackup, | ||||||
getUserSystemFileSize: getUserSystemFileSize, | ||||||
mountPartToBackup: mountPartToBackup, | ||||||
waitForDevice: () => { | ||||||
adb | ||||||
.waitForDevice() | ||||||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -20,18 +20,21 @@ const setText = (cat, id, text) => { | |||||
$("." + cat + "-" + id).text(text); | ||||||
}; | ||||||
|
||||||
// AW : Added Pull Animation | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
const animations = { | ||||||
hideAll: () => { | ||||||
$("#particles-foreground").hide(); | ||||||
$("#particles-background").hide(); | ||||||
$("#push-animation").hide(); | ||||||
$("#pull-animation").hide(); | ||||||
$("#download-animation").hide(); | ||||||
}, | ||||||
particles: () => { | ||||||
if (!localStorage.getItem("animationsDisabled")) { | ||||||
$("#particles-foreground").show(); | ||||||
$("#particles-background").show(); | ||||||
$("#push-animation").hide(); | ||||||
$("#pull-animation").hide(); | ||||||
$("#download-animation").hide(); | ||||||
} else { | ||||||
animations.hideAll(); | ||||||
|
@@ -41,6 +44,7 @@ const animations = { | |||||
if (!localStorage.getItem("animationsDisabled")) { | ||||||
$("#download-animation").show(); | ||||||
$("#push-animation").hide(); | ||||||
$("#pull-animation").hide(); | ||||||
$("#particles-foreground").hide(); | ||||||
$("#particles-background").hide(); | ||||||
} else { | ||||||
|
@@ -49,16 +53,29 @@ const animations = { | |||||
}, | ||||||
push: () => { | ||||||
if (!localStorage.getItem("animationsDisabled")) { | ||||||
$("#pull-animation").hide(); | ||||||
$("#push-animation").show(); | ||||||
$("#download-animation").hide(); | ||||||
$("#particles-foreground").hide(); | ||||||
$("#particles-background").hide(); | ||||||
} else { | ||||||
animations.hideAll(); | ||||||
} | ||||||
}, | ||||||
pull: () => { | ||||||
if (!localStorage.getItem("animationsDisabled")) { | ||||||
$("#pull-animation").show(); | ||||||
$("#push-animation").hide(); | ||||||
$("#download-animation").hide(); | ||||||
$("#particles-foreground").hide(); | ||||||
$("#particles-background").hide(); | ||||||
} else { | ||||||
animations.hideAll(); | ||||||
} | ||||||
} | ||||||
}; | ||||||
|
||||||
// AW : Added pull animation | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
const views = { | ||||||
hideAll: () => hideAll("views"), | ||||||
show: (id, animation) => { | ||||||
|
@@ -87,6 +104,9 @@ const views = { | |||||
case "push": | ||||||
animations.push(); | ||||||
break; | ||||||
case "pull": | ||||||
animations.pull(); | ||||||
break; | ||||||
default: | ||||||
animations.hideAll(); | ||||||
} | ||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#views-backup-device.main.container.views(hidden='hidden') | ||
.row | ||
.col-xs-6 | ||
img(style='height: 350px; margin: auto; display: block;', src='../screens/Screen6.jpg') | ||
.col-xs-6(style='height: 100%') | ||
h4.user-install-header#device-name(style='font-weight: bold;') Device Backup | ||
- var backupsize = 0; | ||
span#sizeinfo(style='color:blue;') Refreshing ... | ||
br | ||
br | ||
p | ||
| Please give a name to your backup | ||
form.form-horizontal | ||
.form-group | ||
.col-xs-3 | ||
label.control-label Name | ||
.col-xs-9 | ||
input#text-backname.form-control.space(type="text", value="") | ||
p | ||
| | ||
| | ||
| This operation will take a while ! Are you sure ? | ||
button#btn-modal-select-device.btn.btn-primary(type='button', style='width: 100%; margin-top: 50px;', onclick="ipcRenderer.send('user:backup:start',(global.BackupName));") Yep, let's go ! | ||
button#btn-device.btn.btn-default(type='button', style='width: 100%;margin-top: 50px;', onclick="ipcRenderer.send('restart');") Not now | ||
script. | ||
$("#text-backname").one("change", () => { | ||
global.BackupName=document.getElementById("text-backname").value; | ||
}); | ||
ipcRenderer.on("user:backup", (event,backupConfig, installConfig) => { | ||
if (backupConfig<1000) | ||
document.getElementById("sizeinfo").innerHTML = "Please be sure to have at least #[b "+backupConfig.toFixed(2)+" Go] free on your hardrive."; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. indentation |
||
else | ||
document.getElementById("sizeinfo").innerHTML = "Please be sure to have at least #[b "+Math.round(backupConfig)+" Go] free on your hardrive."; | ||
footer.underText.set("Choose a backup name"); | ||
//$("#sizeinfo").text("Please be sure to have at least #[b "+backupConfig+" Go] free on your hard-drive."); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. still needed? |
||
var d = new Date(); | ||
var dateback = d.getFullYear() +"-"+ (d.getMonth()+1) + "-" + d.getDate() + "_" +d.getHours() + d.getMinutes(); | ||
$("#text-backname").attr("value",installConfig.codename+"_"+dateback); | ||
global.BackupName = installConfig.codename+"_"+dateback; | ||
views.show("backup-device"); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#views-backup-restore-done.main.container.views(hidden='hidden') | ||
.row | ||
.col-xs-6 | ||
img(style='height: 350px; margin: auto; display: block;', src='../screens/Screen6.jpg') | ||
.col-xs-6 | ||
h4(style='font-weight: bold;') Success! | ||
span#task(style='color:blue;') Status | ||
|
||
button.btn.btn-info(type='button', style='width: 100%; margin-top: 20px;', onclick="ipcRenderer.send('restart');") Finish | ||
script. | ||
ipcRenderer.on("user:backuprestore:done", (event, task) => { | ||
document.getElementById("task").innerHTML = "Your "+task+" "+global.BackupName+" is finished !"; | ||
views.show("backup-restore-done"); | ||
$("#progress").width("0%"); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this an intended duplication?