mirror of
https://github.com/upscayl/upscayl.git
synced 2025-02-07 15:01:24 +01:00
Fix file: protocol bug when mixed with ? (for cache busting)
This commit is contained in:
parent
213b15aea3
commit
b8641592ba
@ -70,6 +70,16 @@ app.on("ready", async () => {
|
|||||||
// Quit the app once all windows are closed
|
// Quit the app once all windows are closed
|
||||||
app.on("window-all-closed", app.quit);
|
app.on("window-all-closed", app.quit);
|
||||||
|
|
||||||
|
// Fix file:// + ? by registering a new protocol
|
||||||
|
app.whenReady().then(() => {
|
||||||
|
const { protocol } = require("electron");
|
||||||
|
protocol.registerFileProtocol('local', (request, callback) => {
|
||||||
|
const pathname = decodeURIComponent(request.url.replace('local://', ''));
|
||||||
|
const parts = pathname.split('?');
|
||||||
|
callback(parts[0]);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
// ! DONT FORGET TO RESTART THE APP WHEN YOU CHANGE CODE HERE
|
// ! DONT FORGET TO RESTART THE APP WHEN YOU CHANGE CODE HERE
|
||||||
|
|
||||||
ipcMain.handle(commands.SELECT_FILE, async () => {
|
ipcMain.handle(commands.SELECT_FILE, async () => {
|
||||||
@ -113,8 +123,8 @@ ipcMain.handle(commands.SELECT_OUTPUT, async (event, payload) => {
|
|||||||
return "cancelled";
|
return "cancelled";
|
||||||
} else {
|
} else {
|
||||||
console.log(filePath);
|
console.log(filePath);
|
||||||
if(fs.existsSync(tmpPath + "/scaled" + fileExt)) {
|
if(fs.existsSync(tmpPath + "scaled" + fileExt)) {
|
||||||
fs.copyFileSync(tmpPath + "/scaled" + fileExt, filePath);
|
fs.copyFileSync(tmpPath + "scaled" + fileExt, filePath);
|
||||||
}
|
}
|
||||||
return filePath;
|
return filePath;
|
||||||
}
|
}
|
||||||
@ -123,8 +133,8 @@ ipcMain.handle(commands.SELECT_OUTPUT, async (event, payload) => {
|
|||||||
ipcMain.handle(commands.REPLACE_ORIGINAL, async (event, payload) => {
|
ipcMain.handle(commands.REPLACE_ORIGINAL, async (event, payload) => {
|
||||||
const original = payload.original;
|
const original = payload.original;
|
||||||
const fileExt = parse(original).ext;
|
const fileExt = parse(original).ext;
|
||||||
if(fs.existsSync(tmpPath + "/scaled" + fileExt)) {
|
if(fs.existsSync(tmpPath + "scaled" + fileExt)) {
|
||||||
fs.copyFileSync(tmpPath + "/scaled" + fileExt, original);
|
fs.copyFileSync(tmpPath + "scaled" + fileExt, original);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -152,9 +162,9 @@ ipcMain.on(commands.UPSCAYL, async (event, payload) => {
|
|||||||
execPath,
|
execPath,
|
||||||
[
|
[
|
||||||
"-i",
|
"-i",
|
||||||
tmpPath + "/original" + fileExt,
|
tmpPath + "original" + fileExt,
|
||||||
"-o",
|
"-o",
|
||||||
tmpPath + "/scaled" + fileExt,
|
tmpPath + "scaled" + fileExt,
|
||||||
"-s",
|
"-s",
|
||||||
scale === 2 ? 4 : scale,
|
scale === 2 ? 4 : scale,
|
||||||
"-m",
|
"-m",
|
||||||
@ -182,7 +192,7 @@ ipcMain.on(commands.UPSCAYL, async (event, payload) => {
|
|||||||
console.log("Done upscaling");
|
console.log("Done upscaling");
|
||||||
mainWindow.webContents.send(
|
mainWindow.webContents.send(
|
||||||
commands.UPSCAYL_DONE,
|
commands.UPSCAYL_DONE,
|
||||||
outputDir + "/scaled" + fileExt
|
outputDir + "scaled" + fileExt
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -341,7 +341,7 @@ const Home = () => {
|
|||||||
<img
|
<img
|
||||||
className="h-full w-full object-contain"
|
className="h-full w-full object-contain"
|
||||||
src={
|
src={
|
||||||
"file://" + `${upscaledImagePath ? upscaledImagePath : imagePath}`
|
"local://" + `${upscaledImagePath ? upscaledImagePath : imagePath}`
|
||||||
}
|
}
|
||||||
draggable="false"
|
draggable="false"
|
||||||
alt=""
|
alt=""
|
||||||
@ -350,7 +350,7 @@ const Home = () => {
|
|||||||
<ReactCompareSlider
|
<ReactCompareSlider
|
||||||
itemOne={
|
itemOne={
|
||||||
<ReactCompareSliderImage
|
<ReactCompareSliderImage
|
||||||
src={"file://" + imagePath + "?" + Date.now()}
|
src={"local://" + imagePath + "?" + Date.now()}
|
||||||
alt="Original"
|
alt="Original"
|
||||||
style={{
|
style={{
|
||||||
objectFit: "contain",
|
objectFit: "contain",
|
||||||
@ -359,7 +359,7 @@ const Home = () => {
|
|||||||
}
|
}
|
||||||
itemTwo={
|
itemTwo={
|
||||||
<ReactCompareSliderImage
|
<ReactCompareSliderImage
|
||||||
src={"file://" + upscaledImagePath + "?" + Date.now()}
|
src={"local://" + upscaledImagePath + "?" + Date.now()}
|
||||||
alt="Upscayl"
|
alt="Upscayl"
|
||||||
style={{
|
style={{
|
||||||
objectFit: "contain",
|
objectFit: "contain",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user