diff options
author | Chocobozzz <me@florianbigard.com> | 2018-07-16 14:38:11 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-07-16 14:38:11 +0200 |
commit | 337ba64efc5a54e83884f33a91de4012ed9b7d11 (patch) | |
tree | 8d515d7ebf4be6ca1d6d69ef16fb91cc7e4fb19b | |
parent | f4001cf408a99049d01a356bfb20a62342de06ea (diff) | |
download | PeerTube-337ba64efc5a54e83884f33a91de4012ed9b7d11.tar.gz PeerTube-337ba64efc5a54e83884f33a91de4012ed9b7d11.tar.zst PeerTube-337ba64efc5a54e83884f33a91de4012ed9b7d11.zip |
Parse log script parse the last updated log
-rw-r--r-- | client/src/app/videos/+video-edit/shared/video-caption-add-modal.component.ts | 7 | ||||
-rwxr-xr-x | scripts/parse-log.ts | 18 |
2 files changed, 17 insertions, 8 deletions
diff --git a/client/src/app/videos/+video-edit/shared/video-caption-add-modal.component.ts b/client/src/app/videos/+video-edit/shared/video-caption-add-modal.component.ts index 5498dac22..d084a4908 100644 --- a/client/src/app/videos/+video-edit/shared/video-caption-add-modal.component.ts +++ b/client/src/app/videos/+video-edit/shared/video-caption-add-modal.component.ts | |||
@@ -76,13 +76,8 @@ export class VideoCaptionAddModalComponent extends FormReactive implements OnIni | |||
76 | 76 | ||
77 | this.captionAdded.emit({ | 77 | this.captionAdded.emit({ |
78 | language: languageObject, | 78 | language: languageObject, |
79 | captionfile: this.form.value['captionfile'] | 79 | captionfile: this.form.value[ 'captionfile' ] |
80 | }) | 80 | }) |
81 | // | ||
82 | // this.form.patchValue({ | ||
83 | // language: null, | ||
84 | // captionfile: null | ||
85 | // }) | ||
86 | 81 | ||
87 | this.form.reset() | 82 | this.form.reset() |
88 | } | 83 | } |
diff --git a/scripts/parse-log.ts b/scripts/parse-log.ts index 4e4f3df63..dccab0884 100755 --- a/scripts/parse-log.ts +++ b/scripts/parse-log.ts | |||
@@ -1,5 +1,5 @@ | |||
1 | import * as program from 'commander' | 1 | import * as program from 'commander' |
2 | import { createReadStream, readdirSync } from 'fs' | 2 | import { createReadStream, readdirSync, statSync } from 'fs' |
3 | import { join } from 'path' | 3 | import { join } from 'path' |
4 | import { createInterface } from 'readline' | 4 | import { createInterface } from 'readline' |
5 | import * as winston from 'winston' | 5 | import * as winston from 'winston' |
@@ -53,7 +53,7 @@ const logLevels = { | |||
53 | } | 53 | } |
54 | 54 | ||
55 | const logFiles = readdirSync(CONFIG.STORAGE.LOG_DIR) | 55 | const logFiles = readdirSync(CONFIG.STORAGE.LOG_DIR) |
56 | const lastLogFile = logFiles[logFiles.length - 1] | 56 | const lastLogFile = getNewestFile(logFiles, CONFIG.STORAGE.LOG_DIR) |
57 | 57 | ||
58 | const path = join(CONFIG.STORAGE.LOG_DIR, lastLogFile) | 58 | const path = join(CONFIG.STORAGE.LOG_DIR, lastLogFile) |
59 | console.log('Opening %s.', path) | 59 | console.log('Opening %s.', path) |
@@ -77,3 +77,17 @@ function toTimeFormat (time: string) { | |||
77 | 77 | ||
78 | return new Date(timestamp).toISOString() | 78 | return new Date(timestamp).toISOString() |
79 | } | 79 | } |
80 | |||
81 | // Thanks: https://stackoverflow.com/a/37014317 | ||
82 | function getNewestFile (files: string[], basePath: string) { | ||
83 | const out = [] | ||
84 | |||
85 | files.forEach(file => { | ||
86 | const stats = statSync(basePath + '/' + file) | ||
87 | if (stats.isFile()) out.push({ file, mtime: stats.mtime.getTime() }) | ||
88 | }) | ||
89 | |||
90 | out.sort((a, b) => b.mtime - a.mtime) | ||
91 | |||
92 | return (out.length > 0) ? out[ 0 ].file : '' | ||
93 | } \ No newline at end of file | ||