refactor, enhance: ドライブ引数のオブジェクト化, 追加時のcomment指定 (#8180)

* refactor: ドライブの引数をオブジェクト化する Resolve #8177

* Resolve #8181

* fix

* archivePath
This commit is contained in:
MeiMei
2022-01-23 22:52:35 +09:00
committed by GitHub
parent d8905a9588
commit 7aecf15f94
13 changed files with 82 additions and 47 deletions

View File

@@ -10,16 +10,27 @@ import { DriveFiles } from '@/models/index';
const logger = driveLogger.createSubLogger('downloader');
export default async (
url: string,
user: { id: User['id']; host: User['host'] } | null,
folderId: DriveFolder['id'] | null = null,
uri: string | null = null,
type Args = {
url: string;
user: { id: User['id']; host: User['host'] } | null;
folderId?: DriveFolder['id'] | null;
uri?: string | null;
sensitive?: boolean;
force?: boolean;
isLink?: boolean;
comment?: string | null;
};
export async function uploadFromUrl({
url,
user,
folderId = null,
uri = null,
sensitive = false,
force = false,
link = false,
isLink = false,
comment = null
): Promise<DriveFile> => {
}: Args): Promise<DriveFile> {
let name = new URL(url).pathname.split('/').pop() || null;
if (name == null || !DriveFiles.validateFileName(name)) {
name = null;
@@ -41,7 +52,7 @@ export default async (
let error;
try {
driveFile = await addFile(user, path, name, comment, folderId, force, link, url, uri, sensitive);
driveFile = await addFile({ user, path, name, comment, folderId, force, isLink, url, uri, sensitive });
logger.succ(`Got: ${driveFile.id}`);
} catch (e) {
error = e;
@@ -59,4 +70,4 @@ export default async (
} else {
return driveFile!;
}
};
}