better handling all around for files and symlinks
This commit is contained in:
@@ -1,17 +1,19 @@
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import { error } from "@sveltejs/kit";
|
||||
import { getStreamInfo } from "$lib/database.js";
|
||||
import { dev } from "$app/environment";
|
||||
import { STREAM_JSON_LOCATION } from '$env/static/private';
|
||||
|
||||
let getOriginalJson, writeSideloadJson;
|
||||
export let actions;
|
||||
|
||||
// utilities for manipulating original stream JSONs
|
||||
if (dev) {
|
||||
const jsonFolder = './db/stream_json/';
|
||||
const jsonFolder = path.resolve(STREAM_JSON_LOCATION);
|
||||
|
||||
getOriginalJson = function (streamId) {
|
||||
const filePath = jsonFolder + streamId + ".sideload.json";
|
||||
const filePath = path.join(jsonFolder, streamId + ".sideload.json");
|
||||
if (fs.existsSync(filePath)) {
|
||||
const jsonString = fs.readFileSync(filePath, 'utf8');
|
||||
return jsonString;
|
||||
@@ -21,7 +23,7 @@ if (dev) {
|
||||
}
|
||||
|
||||
writeSideloadJson = function (streamId, newJson) {
|
||||
const filePath = jsonFolder + streamId + ".sideload.json";
|
||||
const filePath = path.join(jsonFolder, streamId + ".sideload.json");
|
||||
fs.writeFileSync(filePath, JSON.stringify(newJson), 'utf8');
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user