diff --git a/frontend/src/views/settings/Profile.vue b/frontend/src/views/settings/Profile.vue index 328b2f1a..8aafccb6 100644 --- a/frontend/src/views/settings/Profile.vue +++ b/frontend/src/views/settings/Profile.vue @@ -44,7 +44,7 @@ -
+
import { useAuthStore } from "@/stores/auth"; import { useLayoutStore } from "@/stores/layout"; -import { users as api, settings } from "@/api"; +import { users as api } from "@/api"; import AceEditorTheme from "@/components/settings/AceEditorTheme.vue"; import Languages from "@/components/settings/Languages.vue"; import { computed, inject, onMounted, ref } from "vue"; import { useI18n } from "vue-i18n"; +import { authMethod, noAuth } from "@/utils/constants"; const layoutStore = useLayoutStore(); const authStore = useAuthStore(); @@ -142,7 +143,6 @@ onMounted(async () => { dateFormat.value = authStore.user.dateFormat; aceEditorTheme.value = authStore.user.aceEditorTheme; layoutStore.loading = false; - const { authMethod } = await settings.get(); isCurrentPasswordRequired.value = authMethod == "json"; return true; diff --git a/http/resource.go b/http/resource.go index 9fe4caa6..0a8da271 100644 --- a/http/resource.go +++ b/http/resource.go @@ -280,6 +280,12 @@ func writeFile(afs afero.Fs, dst string, in io.Reader, fileMode, dirMode fs.File return nil, err } + // Sync the file to ensure all data is written to storage. + // to prevent file corruption. + if err := file.Sync(); err != nil { + return nil, err + } + // Gets the info about the file. info, err := file.Stat() if err != nil { diff --git a/http/tus_handlers.go b/http/tus_handlers.go index d11920ae..498d776f 100644 --- a/http/tus_handlers.go +++ b/http/tus_handlers.go @@ -256,6 +256,12 @@ func tusPatchHandler() handleFunc { return http.StatusInternalServerError, fmt.Errorf("could not write to file: %w", err) } + // Sync the file to ensure all data is written to storage + // to prevent file corruption. + if err := openFile.Sync(); err != nil { + return http.StatusInternalServerError, fmt.Errorf("could not sync file: %w", err) + } + newOffset := uploadOffset + bytesWritten w.Header().Set("Upload-Offset", strconv.FormatInt(newOffset, 10))