chatCompression support for node
This commit is contained in:
@@ -166,13 +166,11 @@
|
|||||||
</Check>
|
</Check>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{#if !isNodeServer}
|
|
||||||
<div class="flex items-center mt-4">
|
<div class="flex items-center mt-4">
|
||||||
<Check bind:check={DBState.db.chatCompression} name={language.experimentalChatCompression}>
|
<Check bind:check={DBState.db.chatCompression} name={language.experimentalChatCompression}>
|
||||||
<Help key="experimentalChatCompressionDesc"/><Help key="experimental"/>
|
<Help key="experimentalChatCompressionDesc"/><Help key="experimental"/>
|
||||||
</Check>
|
</Check>
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
|
||||||
{/if}
|
{/if}
|
||||||
{#if DBState.db.showUnrecommended}
|
{#if DBState.db.showUnrecommended}
|
||||||
<div class="flex items-center mt-4">
|
<div class="flex items-center mt-4">
|
||||||
|
|||||||
@@ -7,10 +7,11 @@ import {
|
|||||||
readDir,
|
readDir,
|
||||||
remove
|
remove
|
||||||
} from "@tauri-apps/plugin-fs"
|
} from "@tauri-apps/plugin-fs"
|
||||||
import { forageStorage, isTauri } from "../globalApi.svelte"
|
import { forageStorage, isNodeServer, isTauri } from "../globalApi.svelte"
|
||||||
import { DBState } from "../stores.svelte"
|
import { DBState } from "../stores.svelte"
|
||||||
import { hubURL } from "../characterCards"
|
import { hubURL } from "../characterCards"
|
||||||
import type { AccountStorage } from "../storage/accountStorage"
|
import type { AccountStorage } from "../storage/accountStorage"
|
||||||
|
import type { NodeStorage } from "../storage/nodeStorage"
|
||||||
|
|
||||||
export const coldStorageHeader = '\uEF01COLDSTORAGE\uEF01'
|
export const coldStorageHeader = '\uEF01COLDSTORAGE\uEF01'
|
||||||
|
|
||||||
@@ -44,7 +45,20 @@ async function getColdStorageItem(key:string) {
|
|||||||
}
|
}
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
else if(isNodeServer){
|
||||||
|
try {
|
||||||
|
const storage = forageStorage.realStorage as NodeStorage
|
||||||
|
const f = await storage.getItem('coldstorage/' + key)
|
||||||
|
if(!f){
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
const text = new TextDecoder().decode(await decompress(new Uint8Array(f)))
|
||||||
|
return JSON.parse(text)
|
||||||
|
}
|
||||||
|
catch (error) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
}
|
||||||
else if(isTauri){
|
else if(isTauri){
|
||||||
try {
|
try {
|
||||||
const f = await readFile('./coldstorage/'+key+'.json', {
|
const f = await readFile('./coldstorage/'+key+'.json', {
|
||||||
@@ -108,6 +122,16 @@ async function setColdStorageItem(key:string, value:any) {
|
|||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
else if(isNodeServer){
|
||||||
|
try {
|
||||||
|
const storage = forageStorage.realStorage as NodeStorage
|
||||||
|
await storage.setItem('coldstorage/' + key, compressed)
|
||||||
|
return
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
else if(isTauri){
|
else if(isTauri){
|
||||||
try {
|
try {
|
||||||
if(!(await exists('./coldstorage'))){
|
if(!(await exists('./coldstorage'))){
|
||||||
|
|||||||
Reference in New Issue
Block a user