plugins: can_overwrite
Massimo Melina committed
Dec 16, 2023 at 22:37 UTC
590ac8f577908dd2e045d9c02990b59e16c0423a
5 files changed
+8
-4
README.md
+1
@@ -184,6 +184,7 @@ Some actions you can take for improved security:
184
- Appending ?lang=CODE to address will force a specific language
185
- right/ctrl/command click on toggle-all checkbox will invert each checkbox state
186
- Appending `?login=USER:PASSWORD` will automatically log in the browser
187
+- Appending `?overwrite` on uploads, will try override the dont_overwrite_uploading configuration, provided you also have delete permission
188
189
## Contribute
190
dev-plugins.md
+2
-1
@@ -363,8 +363,9 @@ Where `h` is just `import { createElement as h } from 'react'`.
363
364
## API version history
365
366
-- 8.6 (v0.51.0)
366
+- 8.61 (v0.51.0)
367
- plugin's own hfs-lang files
368
+ - props.can_overwrite
369
- 8.5 (v0.49.0)
370
- new event: entry
371
- exports.onDirEntry: entry.icon
src/api.file_list.ts
+3
-1
@@ -12,6 +12,7 @@ import { descriptIon, DESCRIPT_ION, getCommentFor, areCommentsEnabled } from './
12
import { basename } from 'path'
13
import { getConnection, updateConnection } from './connections'
14
import { ctxAdminAccess } from './adminApis'
15
+import { dontOverwriteUploading } from './upload'
16
17
export interface DirEntry { n:string, s?:number, m?:Date, c?:Date, p?: string, comment?: string, web?: boolean, url?: string }
18
@@ -37,7 +38,8 @@ export const get_file_list: ApiHandler = async ({ uri, offset, limit, search, c,
38
const can_delete = admin || hasPermission(fakeChild, 'can_delete', ctx)
39
const can_archive = admin || hasPermission(fakeChild, 'can_archive', ctx)
40
const can_comment = can_upload && areCommentsEnabled()
40
- const props = { can_archive, can_upload, can_delete, accept: node.accept, can_comment }
41
+ const can_overwrite = can_upload && (can_delete || !dontOverwriteUploading.get())
42
+ const props = { can_archive, can_upload, can_delete, can_overwrite, accept: node.accept, can_comment }
43
if (!list)
44
return { ...props, list: await asyncGeneratorToArray(produceEntries()) }
45
setTimeout(async () => {
src/const.ts
+1
-1
@@ -7,7 +7,7 @@ import { mkdirSync } from 'fs'
7
import { basename, dirname, join } from 'path'
8
export * from './cross-const'
9
10
-export const API_VERSION = 8.6
10
+export const API_VERSION = 8.61
11
export const COMPATIBLE_API_VERSION = 1 // while changes in the api are not breaking, this number stays the same, otherwise it is made equal to API_VERSION
12
export const HFS_REPO = 'rejetto/hfs'
13
src/upload.ts
+1
-1
@@ -19,7 +19,7 @@ import { setCommentFor } from './comments'
19
20
export const deleteUnfinishedUploadsAfter = defineConfig<undefined|number>('delete_unfinished_uploads_after', 86_400)
21
export const minAvailableMb = defineConfig('min_available_mb', 100)
22
-const dontOverwriteUploading = defineConfig('dont_overwrite_uploading', false)
22
+export const dontOverwriteUploading = defineConfig('dont_overwrite_uploading', false)
23
24
const waitingToBeDeleted: Record<string, ReturnType<typeof setTimeout>> = {}
25