Feature: add remote file delete , picBed management

First version of PicList.
In album, you can delete remote file now.
Add picBed management
function.
This commit is contained in:
萌萌哒赫萝
2023-02-15 23:36:47 +08:00
parent 7421322475
commit efeadb8fb8
355 changed files with 12428 additions and 883 deletions

View File

@@ -48,7 +48,7 @@ class Server {
if (request.method === 'POST') {
if (!routers.getHandler(request.url!)) {
logger.warn(`[PicGo Server] don't support [${request.url}] url`)
logger.warn(`[PicList Server] don't support [${request.url}] url`)
handleResponse({
response,
statusCode: 404,
@@ -66,7 +66,7 @@ class Server {
try {
postObj = (body === '') ? {} : JSON.parse(body)
} catch (err: any) {
logger.error('[PicGo Server]', err)
logger.error('[PicList Server]', err)
return handleResponse({
response,
body: {
@@ -75,7 +75,7 @@ class Server {
}
})
}
logger.info('[PicGo Server] get the request', body)
logger.info('[PicList Server] get the request', body)
const handler = routers.getHandler(request.url!)
handler!({
...postObj,
@@ -84,7 +84,7 @@ class Server {
})
}
} else {
logger.warn(`[PicGo Server] don't support [${request.method}] method`)
logger.warn(`[PicList Server] don't support [${request.method}] method`)
response.statusCode = 404
response.end()
}
@@ -92,7 +92,7 @@ class Server {
// port as string is a bug
private listen = (port: number | string) => {
logger.info(`[PicGo Server] is listening at ${port}`)
logger.info(`[PicList Server] is listening at ${port}`)
if (typeof port === 'string') {
port = parseInt(port, 10)
}
@@ -103,7 +103,7 @@ class Server {
await axios.post(ensureHTTPLink(`${this.config.host}:${port}/heartbeat`))
this.shutdown(true)
} catch (e) {
logger.warn(`[PicGo Server] ${port} is busy, trying with port ${(port as number) + 1}`)
logger.warn(`[PicList Server] ${port} is busy, trying with port ${(port as number) + 1}`)
// fix a bug: not write an increase number to config file
// to solve the auto number problem
this.listen((port as number) + 1)
@@ -122,7 +122,7 @@ class Server {
shutdown (hasStarted?: boolean) {
this.httpServer.close()
if (!hasStarted) {
logger.info('[PicGo Server] shutdown')
logger.info('[PicList Server] shutdown')
}
}

View File

@@ -8,7 +8,7 @@ import { uploadChoosedFiles, uploadClipboardFiles } from 'apis/app/uploader/apis
import path from 'path'
import { dbPathDir } from 'apis/core/datastore/dbChecker'
const STORE_PATH = dbPathDir()
const LOG_PATH = path.join(STORE_PATH, 'picgo.log')
const LOG_PATH = path.join(STORE_PATH, 'piclist.log')
const errorMessage = `upload error. see ${LOG_PATH} for more detail.`
@@ -22,9 +22,9 @@ router.post('/upload', async ({
try {
if (list.length === 0) {
// upload with clipboard
logger.info('[PicGo Server] upload clipboard file')
logger.info('[PicList Server] upload clipboard file')
const res = await uploadClipboardFiles()
logger.info('[PicGo Server] upload result:', res)
logger.info('[PicList Server] upload result:', res)
if (res) {
handleResponse({
response,
@@ -43,7 +43,7 @@ router.post('/upload', async ({
})
}
} else {
logger.info('[PicGo Server] upload files in list')
logger.info('[PicList Server] upload files in list')
// upload with files
const pathList = list.map(item => {
return {
@@ -52,7 +52,7 @@ router.post('/upload', async ({
})
const win = windowManager.getAvailableWindow()
const res = await uploadChoosedFiles(win.webContents, pathList)
logger.info('[PicGo Server] upload result', res.join(' ; '))
logger.info('[PicList Server] upload result', res.join(' ; '))
if (res.length) {
handleResponse({
response,

View File

@@ -19,7 +19,7 @@ export const handleResponse = ({
body?: any
}) => {
if (body?.success === false) {
logger.warn('[PicGo Server] upload failed, see picgo.log for more detail ↑')
logger.warn('[PicList Server] upload failed, see piclist.log for more detail ↑')
}
response.writeHead(statusCode, header)
response.write(JSON.stringify(body))