mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Merge branch 'staging' into woo-yeah
This commit is contained in:
@ -74,12 +74,18 @@ async function writeCharacterData(inputFile, data, outputFile, request, crop = u
|
||||
* Read the image, resize, and save it as a PNG into the buffer.
|
||||
* @returns {Promise<Buffer>} Image buffer
|
||||
*/
|
||||
function getInputImage() {
|
||||
if (Buffer.isBuffer(inputFile)) {
|
||||
return parseImageBuffer(inputFile, crop);
|
||||
}
|
||||
async function getInputImage() {
|
||||
try {
|
||||
if (Buffer.isBuffer(inputFile)) {
|
||||
return await parseImageBuffer(inputFile, crop);
|
||||
}
|
||||
|
||||
return tryReadImage(inputFile, crop);
|
||||
return await tryReadImage(inputFile, crop);
|
||||
} catch (error) {
|
||||
const message = Buffer.isBuffer(inputFile) ? 'Failed to read image buffer.' : `Failed to read image: ${inputFile}.`;
|
||||
console.warn(message, 'Using a fallback image.', error);
|
||||
return await fs.promises.readFile(defaultAvatarPath);
|
||||
}
|
||||
}
|
||||
|
||||
const inputImage = await getInputImage();
|
||||
|
@ -458,7 +458,8 @@ export function getPasswordSalt() {
|
||||
*/
|
||||
export function getCookieSessionName() {
|
||||
// Get server hostname and hash it to generate a session suffix
|
||||
const suffix = crypto.createHash('sha256').update(os.hostname()).digest('hex').slice(0, 8);
|
||||
const hostname = os.hostname() || 'localhost';
|
||||
const suffix = crypto.createHash('sha256').update(hostname).digest('hex').slice(0, 8);
|
||||
return `session-${suffix}`;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user