Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
544 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
libs/Universal-PicGo-Store/src/lib/base/electron/TextFile.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
* GNU GENERAL PUBLIC LICENSE | ||
* Version 3, 29 June 2007 | ||
* | ||
* Copyright (C) 2024 Terwer, Inc. <https://terwer.space/> | ||
* Everyone is permitted to copy and distribute verbatim copies | ||
* of this license document, but changing it is not allowed. | ||
*/ | ||
|
||
import { SyncAdapter } from "@commonify/lowdb" | ||
import { win } from "../../utils" | ||
|
||
export class TextFileSync implements SyncAdapter<string> { | ||
// PathLike | ||
#tempFilename: any | ||
// PathLike | ||
#filename: any | ||
|
||
// PathLike | ||
constructor(filename: any) { | ||
const path = win.require("path") | ||
this.#filename = filename | ||
const f = filename.toString() | ||
this.#tempFilename = path.join(path.dirname(f), `.${path.basename(f)}.tmp`) | ||
} | ||
|
||
read(): string | null { | ||
let data | ||
|
||
try { | ||
const fs = win.fs | ||
data = fs.readFileSync(this.#filename, "utf-8") | ||
} catch (e) { | ||
if ((e as NodeJS.ErrnoException).code === "ENOENT") { | ||
return null | ||
} | ||
throw e | ||
} | ||
|
||
return data | ||
} | ||
|
||
write(str: string): void { | ||
const fs = win.fs | ||
fs.writeFileSync(this.#tempFilename, str) | ||
fs.renameSync(this.#tempFilename, this.#filename) | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
libs/Universal-PicGo-Store/src/lib/base/electron/signalExitShim.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/* | ||
* GNU GENERAL PUBLIC LICENSE | ||
* Version 3, 29 June 2007 | ||
* | ||
* Copyright (C) 2024 Terwer, Inc. <https://terwer.space/> | ||
* Everyone is permitted to copy and distribute verbatim copies | ||
* of this license document, but changing it is not allowed. | ||
*/ | ||
|
||
/** | ||
* This is a browser shim that provides the same functional interface | ||
* as the main node export, but it does nothing. | ||
* @module | ||
*/ | ||
export const onExit: (cb: any, opts?: { alwaysLast?: boolean }) => () => void = () => () => {} | ||
export const load = () => {} | ||
export const unload = () => {} |
Oops, something went wrong.