forked from Shinonome/dots-hyprland
booru: cleaner download
This commit is contained in:
@@ -20,28 +20,21 @@ Button {
|
|||||||
property string downloadPath
|
property string downloadPath
|
||||||
property string nsfwPath
|
property string nsfwPath
|
||||||
property string fileName: decodeURIComponent((imageData.file_url).substring((imageData.file_url).lastIndexOf('/') + 1))
|
property string fileName: decodeURIComponent((imageData.file_url).substring((imageData.file_url).lastIndexOf('/') + 1))
|
||||||
|
property string filePath: `${root.previewDownloadPath}/${root.fileName}`
|
||||||
|
|
||||||
property bool showActions: false
|
property bool showActions: false
|
||||||
|
|
||||||
Process {
|
Process {
|
||||||
id: downloadProcess
|
id: downloadProcess
|
||||||
running: false
|
running: false
|
||||||
command: ["bash", "-c", `curl '${root.imageData.preview_url ?? root.imageData.sample_url}' -o '${root.previewDownloadPath}/${root.fileName}' && echo 'done'`]
|
command: ["bash", "-c", `[ -f ${root.filePath} ] || curl '${root.imageData.preview_url ?? root.imageData.sample_url}' -o '${root.filePath}'`]
|
||||||
stdout: SplitParser {
|
onExited: (exitCode, exitStatus) => {
|
||||||
onRead: (data) => {
|
imageObject.source = `${previewDownloadPath}/${root.fileName}`
|
||||||
// console.log("Download output:", data)
|
|
||||||
if(data.includes("done")) {
|
|
||||||
imageObject.source = `${previewDownloadPath}/${root.fileName}`
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
if (root.manualDownload) {
|
if (root.manualDownload) {
|
||||||
// console.log("Manual download triggered")
|
|
||||||
// console.log("Image data:", JSON.stringify(root.imageData))
|
|
||||||
// console.log("Download command:", downloadProcess.command.join(" "))
|
|
||||||
downloadProcess.running = true
|
downloadProcess.running = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user