openlist多目录支持
This commit is contained in:
@@ -76,7 +76,7 @@ export async function GET(
|
||||
const { getCachedMetaInfo, setCachedMetaInfo } = await import('@/lib/openlist-cache');
|
||||
const { db } = await import('@/lib/db');
|
||||
|
||||
let metaInfo = getCachedMetaInfo(rootPath);
|
||||
let metaInfo = getCachedMetaInfo();
|
||||
|
||||
if (!metaInfo) {
|
||||
try {
|
||||
@@ -84,7 +84,7 @@ export async function GET(
|
||||
if (metainfoJson) {
|
||||
metaInfo = JSON.parse(metainfoJson);
|
||||
if (metaInfo) {
|
||||
setCachedMetaInfo(rootPath, metaInfo);
|
||||
setCachedMetaInfo(metaInfo);
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
|
||||
@@ -65,7 +65,6 @@ export async function POST(request: NextRequest) {
|
||||
);
|
||||
}
|
||||
|
||||
const rootPath = openListConfig.RootPath || '/';
|
||||
const client = new OpenListClient(
|
||||
openListConfig.URL,
|
||||
openListConfig.Username,
|
||||
@@ -73,7 +72,7 @@ export async function POST(request: NextRequest) {
|
||||
);
|
||||
|
||||
// 读取现有 metainfo (从数据库或缓存)
|
||||
let metaInfo: MetaInfo | null = getCachedMetaInfo(rootPath);
|
||||
let metaInfo: MetaInfo | null = getCachedMetaInfo();
|
||||
|
||||
if (!metaInfo) {
|
||||
try {
|
||||
@@ -132,8 +131,8 @@ export async function POST(request: NextRequest) {
|
||||
await db.setGlobalValue('video.metainfo', metainfoContent);
|
||||
|
||||
// 更新缓存
|
||||
invalidateMetaInfoCache(rootPath);
|
||||
setCachedMetaInfo(rootPath, metaInfo);
|
||||
invalidateMetaInfoCache();
|
||||
setCachedMetaInfo(metaInfo);
|
||||
|
||||
return NextResponse.json({
|
||||
success: true,
|
||||
|
||||
@@ -49,8 +49,6 @@ export async function POST(request: NextRequest) {
|
||||
);
|
||||
}
|
||||
|
||||
const rootPath = openListConfig.RootPath || '/';
|
||||
|
||||
// 从数据库读取 metainfo
|
||||
const metainfoContent = await db.getGlobalValue('video.metainfo');
|
||||
if (!metainfoContent) {
|
||||
@@ -78,8 +76,8 @@ export async function POST(request: NextRequest) {
|
||||
await db.setGlobalValue('video.metainfo', updatedMetainfoContent);
|
||||
|
||||
// 更新缓存
|
||||
invalidateMetaInfoCache(rootPath);
|
||||
setCachedMetaInfo(rootPath, metaInfo);
|
||||
invalidateMetaInfoCache();
|
||||
setCachedMetaInfo(metaInfo);
|
||||
|
||||
// 更新配置中的资源数量
|
||||
if (config.OpenListConfig) {
|
||||
|
||||
@@ -45,8 +45,8 @@ export async function GET(request: NextRequest) {
|
||||
return NextResponse.json({ error: 'OpenList 未配置或未启用' }, { status: 400 });
|
||||
}
|
||||
|
||||
const rootPath = openListConfig.RootPath || '/';
|
||||
const folderPath = `${rootPath}${rootPath.endsWith('/') ? '' : '/'}${folderName}`;
|
||||
// folderName 已经是完整路径,直接使用
|
||||
const folderPath = folderName;
|
||||
const client = new OpenListClient(
|
||||
openListConfig.URL,
|
||||
openListConfig.Username,
|
||||
|
||||
@@ -48,7 +48,6 @@ export async function GET(request: NextRequest) {
|
||||
);
|
||||
}
|
||||
|
||||
const rootPath = openListConfig.RootPath || '/';
|
||||
const client = new OpenListClient(
|
||||
openListConfig.URL,
|
||||
openListConfig.Username,
|
||||
@@ -62,7 +61,7 @@ export async function GET(request: NextRequest) {
|
||||
if (noCache) {
|
||||
// noCache 模式:跳过缓存
|
||||
} else {
|
||||
metaInfo = getCachedMetaInfo(rootPath);
|
||||
metaInfo = getCachedMetaInfo();
|
||||
}
|
||||
|
||||
if (!metaInfo) {
|
||||
@@ -83,7 +82,7 @@ export async function GET(request: NextRequest) {
|
||||
|
||||
// 只有在不是 noCache 模式时才更新缓存
|
||||
if (!noCache) {
|
||||
setCachedMetaInfo(rootPath, metaInfo);
|
||||
setCachedMetaInfo(metaInfo);
|
||||
}
|
||||
} catch (parseError) {
|
||||
console.error('[OpenList List] JSON 解析或验证失败:', parseError);
|
||||
|
||||
@@ -41,8 +41,8 @@ export async function GET(request: NextRequest) {
|
||||
return NextResponse.json({ error: 'OpenList 未配置或未启用' }, { status: 400 });
|
||||
}
|
||||
|
||||
const rootPath = openListConfig.RootPath || '/';
|
||||
const folderPath = `${rootPath}${rootPath.endsWith('/') ? '' : '/'}${folderName}`;
|
||||
// folderName 已经是完整路径,直接使用
|
||||
const folderPath = folderName;
|
||||
const filePath = `${folderPath}/${fileName}`;
|
||||
|
||||
const client = new OpenListClient(
|
||||
|
||||
@@ -40,8 +40,8 @@ export async function POST(request: NextRequest) {
|
||||
return NextResponse.json({ error: 'OpenList 未配置或未启用' }, { status: 400 });
|
||||
}
|
||||
|
||||
const rootPath = openListConfig.RootPath || '/';
|
||||
const folderPath = `${rootPath}${rootPath.endsWith('/') ? '' : '/'}${folder}`;
|
||||
// folder 已经是完整路径,直接使用
|
||||
const folderPath = folder;
|
||||
const client = new OpenListClient(
|
||||
openListConfig.URL,
|
||||
openListConfig.Username,
|
||||
|
||||
Reference in New Issue
Block a user