@@ -91,6 +91,8 @@ import { HttpError } from '@ownclouders/web-client'
91
91
import { dirname } from ' path'
92
92
import { useFileActionsOpenWithApp } from ' ../../composables/actions/files/useFileActionsOpenWithApp'
93
93
import { UnsavedChangesModal } from ' ../Modals'
94
+ import { formatFileSize } from ' ../../helpers'
95
+ import toNumber from ' lodash-es/toNumber'
94
96
95
97
export default defineComponent ({
96
98
name: ' AppWrapper' ,
@@ -126,7 +128,7 @@ export default defineComponent({
126
128
}
127
129
},
128
130
setup(props ) {
129
- const { $gettext } = useGettext ()
131
+ const { $gettext, current : currentLanguage } = useGettext ()
130
132
const appsStore = useAppsStore ()
131
133
const { showMessage, showErrorMessage } = useMessages ()
132
134
const router = useRouter ()
@@ -209,6 +211,10 @@ export default defineComponent({
209
211
210
212
const { applicationMeta } = useAppMeta ({ applicationId: props .applicationId , appsStore })
211
213
214
+ const fileSizeLimit = computed (() => {
215
+ return unref (applicationMeta ).meta ?.fileSizeLimit
216
+ })
217
+
212
218
const pageTitle = computed (() => {
213
219
const { name : appName } = unref (applicationMeta )
214
220
@@ -264,17 +270,24 @@ export default defineComponent({
264
270
})
265
271
}
266
272
267
- const loadFileTask = useTask (function * (signal ) {
273
+ const loadResourceTask = useTask (function * (signal ) {
268
274
try {
269
275
if (! unref (driveAliasAndItem )) {
270
276
yield addMissingDriveAliasAndItem ()
271
277
}
272
-
273
278
space .value = unref (unref (currentFileContext ).space )
274
- resource .value = yield getFileInfo (currentFileContext )
279
+ resource .value = yield getFileInfo (currentFileContext , { signal } )
275
280
resourcesStore .initResourceList ({ currentFolder: null , resources: [unref (resource )] })
276
281
selectedResources .value = [unref (resource )]
282
+ } catch (e ) {
283
+ console .error (e )
284
+ loadingError .value = e
285
+ loading .value = false
286
+ }
287
+ }).restartable ()
277
288
289
+ const loadFileTask = useTask (function * (signal ) {
290
+ try {
278
291
const newExtension = props .importResourceWithExtension (unref (resource ))
279
292
if (newExtension ) {
280
293
const timestamp = DateTime .local ().toFormat (' yyyyMMddHHmmss' )
@@ -318,19 +331,43 @@ export default defineComponent({
318
331
signal
319
332
})
320
333
}
321
- loading .value = false
322
334
} catch (e ) {
323
335
console .error (e )
324
336
loadingError .value = e
337
+ } finally {
325
338
loading .value = false
326
339
}
327
340
}).restartable ()
328
341
329
342
watch (
330
343
currentFileContext ,
331
- () => {
344
+ async () => {
332
345
if (! unref (noResourceLoading )) {
333
- loadFileTask .perform ()
346
+ await loadResourceTask .perform ()
347
+
348
+ if (unref (fileSizeLimit ) && toNumber (unref (resource ).size ) > unref (fileSizeLimit )) {
349
+ dispatchModal ({
350
+ title: $gettext (' File exceeds %{threshold}' , {
351
+ threshold: formatFileSize (unref (fileSizeLimit ), currentLanguage )
352
+ }),
353
+ message: $gettext (
354
+ ' %{resource} exceeds the recommended size of %{threshold} for editing, and may cause performance issues.' ,
355
+ {
356
+ resource: unref (resource ).name ,
357
+ threshold: formatFileSize (unref (fileSizeLimit ), currentLanguage )
358
+ }
359
+ ),
360
+ confirmText: $gettext (' Continue' ),
361
+ onCancel : () => {
362
+ closeApp ()
363
+ },
364
+ onConfirm : () => {
365
+ loadFileTask .perform ()
366
+ }
367
+ })
368
+ } else {
369
+ loadFileTask .perform ()
370
+ }
334
371
}
335
372
},
336
373
{ immediate: true }
0 commit comments