From daa409cd8285633427ffb3a89d3296824365e918 Mon Sep 17 00:00:00 2001 From: rinsuki <428rinsuki+git@gmail.com> Date: Sun, 17 Jun 2018 20:04:19 +0900 Subject: [PATCH] [noImplicitAny: true] src/services/drive --- package.json | 1 + src/services/drive/add-file.ts | 8 ++++---- src/services/drive/upload-from-url.ts | 4 +++- yarn.lock | 6 ++++++ 4 files changed, 14 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 2b81b0369..669172338 100644 --- a/package.json +++ b/package.json @@ -218,6 +218,7 @@ "xev": "2.0.1" }, "devDependencies": { + "@types/file-type": "5.2.1", "@types/jsdom": "11.0.5" } } diff --git a/src/services/drive/add-file.ts b/src/services/drive/add-file.ts index d7f71e866..4167df066 100644 --- a/src/services/drive/add-file.ts +++ b/src/services/drive/add-file.ts @@ -7,7 +7,7 @@ import * as crypto from 'crypto'; import * as _gm from 'gm'; import * as debug from 'debug'; import fileType = require('file-type'); -import prominence = require('prominence'); +const prominence = require('prominence'); import DriveFile, { IMetadata, getDriveFileBucket, IDriveFile } from '../../models/drive-file'; import DriveFolder from '../../models/drive-folder'; @@ -33,7 +33,7 @@ const writeChunks = (name: string, readable: stream.Readable, type: string, meta readable.pipe(writeStream); })); -const writeThumbnailChunks = (name: string, readable: stream.Readable, originalId) => +const writeThumbnailChunks = (name: string, readable: stream.Readable, originalId: mongodb.ObjectID) => getDriveFileThumbnailBucket() .then(bucket => new Promise((resolve, reject) => { const writeStream = bucket.openUploadStream(name, { @@ -89,7 +89,7 @@ export default async function( const calcHash = new Promise((res, rej) => { const readable = fs.createReadStream(path); const hash = crypto.createHash('md5'); - const chunks = []; + const chunks: Buffer[] = []; readable .on('error', rej) .pipe(hash) @@ -201,7 +201,7 @@ export default async function( return driveFolder; }; - const properties = {}; + const properties: {[key: string]: any} = {}; let propPromises: Array> = []; diff --git a/src/services/drive/upload-from-url.ts b/src/services/drive/upload-from-url.ts index e216ca603..f83d57d41 100644 --- a/src/services/drive/upload-from-url.ts +++ b/src/services/drive/upload-from-url.ts @@ -8,10 +8,12 @@ import * as request from 'request'; import { IDriveFile, validateFileName } from '../../models/drive-file'; import create from './add-file'; import config from '../../config'; +import { IUser } from '../../models/user'; +import * as mongodb from "mongodb"; const log = debug('misskey:drive:upload-from-url'); -export default async (url: string, user, folderId = null, uri: string = null): Promise => { +export default async (url: string, user: IUser, folderId: mongodb.ObjectID = null, uri: string = null): Promise => { log(`REQUESTED: ${url}`); let name = URL.parse(url).pathname.split('/').pop(); diff --git a/yarn.lock b/yarn.lock index e4a53091e..cb6a4a622 100644 --- a/yarn.lock +++ b/yarn.lock @@ -176,6 +176,12 @@ version "1.3.0" resolved "https://registry.yarnpkg.com/@types/fancy-log/-/fancy-log-1.3.0.tgz#a61ab476e5e628cd07a846330df53b85e05c8ce0" +"@types/file-type@5.2.1": + version "5.2.1" + resolved "https://registry.yarnpkg.com/@types/file-type/-/file-type-5.2.1.tgz#e7af49e08187b6b7598509c5e416669d25fa3461" + dependencies: + "@types/node" "*" + "@types/form-data@*": version "2.2.1" resolved "https://registry.yarnpkg.com/@types/form-data/-/form-data-2.2.1.tgz#ee2b3b8eaa11c0938289953606b745b738c54b1e"