diff options
| author | jw255 | 2018-04-17 18:43:06 +0100 |
|---|---|---|
| committer | jw255 | 2018-04-17 18:43:06 +0100 |
| commit | 8f1837af9400ef0ef5c1cab1e853b46e11b1b76b (patch) | |
| tree | 20e504d4311d938a7569264341d96e8d1d1a934e /src/files.ts | |
| parent | World War Files - changed precondition + filled addSubFileToFolder() function... (diff) | |
| download | medicine-8f1837af9400ef0ef5c1cab1e853b46e11b1b76b.tar.gz medicine-8f1837af9400ef0ef5c1cab1e853b46e11b1b76b.zip | |
Files - now actually works
Diffstat (limited to 'src/files.ts')
| -rw-r--r-- | src/files.ts | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/files.ts b/src/files.ts index a5fd08d..9be0381 100644 --- a/src/files.ts +++ b/src/files.ts @@ -1,11 +1,13 @@ import { Request, Response } from 'express'; import * as fs from 'fs'; +import { logger } from './logger'; import { default as File } from './db/model/File'; import { default as Project } from './db/model/Project'; const CONTENT_BASE_DIRECTORY: string = './files'; const LOG_BASE_DIRECTORY: string = './logs'; + /* tslint:disable */ const path: (filename: string, projectName: string) => string = (filename: string, projectName: string): string => { return `${CONTENT_BASE_DIRECTORY}/${projectName}/${filename}`; @@ -198,6 +200,7 @@ export const createProjectFolder: (name: string) => void = (projName: string): a } export const addSubFileToFolder: (parentId: string, subFileId: string) => Promise<boolean> = async(parentId: string, subFileId: string): Promise<boolean> => { + logger.debug(`adding file ${subFileId}) to directory ${parentId}`) // Fetch parent and subFile object from database const parent: File | null = await File.findOne({ include: [{all: true}], @@ -216,10 +219,10 @@ export const addSubFileToFolder: (parentId: string, subFileId: string) => Promis } // update both objects parent.containedFiles.push(file); - file.parentFolderId = parent.id; + file.parentFolderId = parent.uuid; // save - await parent.save(); await file.save(); + await parent.save(); return true; } |
