diff options
author | Chocobozzz <me@florianbigard.com> | 2019-04-11 17:33:36 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2019-04-12 08:31:06 +0200 |
commit | cda03765fe366f028897e9b02dd4a0a19af3c935 (patch) | |
tree | 4d30303d76f8fd171195a51b1f737a0067987d6c /shared/utils/logs | |
parent | 7b293f28686319242958dff7315cdd8ad74fc15e (diff) | |
download | PeerTube-cda03765fe366f028897e9b02dd4a0a19af3c935.tar.gz PeerTube-cda03765fe366f028897e9b02dd4a0a19af3c935.tar.zst PeerTube-cda03765fe366f028897e9b02dd4a0a19af3c935.zip |
Add ability to delete old remote views
Diffstat (limited to 'shared/utils/logs')
-rw-r--r-- | shared/utils/logs/logs.ts | 23 |
1 files changed, 0 insertions, 23 deletions
diff --git a/shared/utils/logs/logs.ts b/shared/utils/logs/logs.ts index 21adace82..cbb1afb93 100644 --- a/shared/utils/logs/logs.ts +++ b/shared/utils/logs/logs.ts | |||
@@ -1,28 +1,6 @@ | |||
1 | // Thanks: https://stackoverflow.com/a/37014317 | ||
2 | import { stat } from 'fs-extra' | ||
3 | import { makeGetRequest } from '../requests/requests' | 1 | import { makeGetRequest } from '../requests/requests' |
4 | import { LogLevel } from '../../models/server/log-level.type' | 2 | import { LogLevel } from '../../models/server/log-level.type' |
5 | 3 | ||
6 | async function mtimeSortFilesDesc (files: string[], basePath: string) { | ||
7 | const promises = [] | ||
8 | const out: { file: string, mtime: number }[] = [] | ||
9 | |||
10 | for (const file of files) { | ||
11 | const p = stat(basePath + '/' + file) | ||
12 | .then(stats => { | ||
13 | if (stats.isFile()) out.push({ file, mtime: stats.mtime.getTime() }) | ||
14 | }) | ||
15 | |||
16 | promises.push(p) | ||
17 | } | ||
18 | |||
19 | await Promise.all(promises) | ||
20 | |||
21 | out.sort((a, b) => b.mtime - a.mtime) | ||
22 | |||
23 | return out | ||
24 | } | ||
25 | |||
26 | function getLogs (url: string, accessToken: string, startDate: Date, endDate?: Date, level?: LogLevel) { | 4 | function getLogs (url: string, accessToken: string, startDate: Date, endDate?: Date, level?: LogLevel) { |
27 | const path = '/api/v1/server/logs' | 5 | const path = '/api/v1/server/logs' |
28 | 6 | ||
@@ -36,6 +14,5 @@ function getLogs (url: string, accessToken: string, startDate: Date, endDate?: D | |||
36 | } | 14 | } |
37 | 15 | ||
38 | export { | 16 | export { |
39 | mtimeSortFilesDesc, | ||
40 | getLogs | 17 | getLogs |
41 | } | 18 | } |