Skip to content

Commit

Permalink
[full-ci] Support noCache option for public links (#7811)
Browse files Browse the repository at this point in the history
* Do not cache files when opening them from public links

Co-authored-by: Diogo Castro <[email protected]>
  • Loading branch information
dschmidt and diocas authored Oct 17, 2022
1 parent 285e800 commit fac384a
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 12 deletions.
8 changes: 8 additions & 0 deletions changelog/unreleased/bugfix-nocache-pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Bugfix: Do not load files from cache in public links

When apps (i.e Drawio) try to load a file, the browser caches the request.
If the file was modified somewhere else, this causes inconsistent results which prevent saving any changes until the cache is properly cleared.
This had previously been fixed for normal files, but not yet for public links - which we took care of now.

https://github.com/owncloud/web/pull/7811
https://github.com/owncloud/web/pull/7075
9 changes: 7 additions & 2 deletions packages/web-client/src/webdav/getFileContents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,21 @@ export const GetFileContentsFactory = ({ sdk }: WebDavOptions) => {
space: SpaceResource,
{ path }: { path?: string },
{
responseType = 'text'
responseType = 'text',
noCache = true
}: {
responseType?: 'arrayBuffer' | 'blob' | 'text'
noCache?: boolean
} = {}
): Promise<GetFileContentsResponse> {
if (isPublicSpaceResource(space)) {
const res = await sdk.publicFiles.download(
'',
urlJoin(space.webDavPath.replace(/^\/public-files/, ''), path),
space.publicLinkPassword
space.publicLinkPassword,
{
noCache
}
)
res.statusCode = res.status
return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export function useAppFileHandling({
}

// TODO: support query parameters, possibly needs porting away from owncloud-sdk
const getFileContents = async (
const getFileContents = (
fileContext: MaybeRef<FileContext>,
options: { responseType?: 'arrayBuffer' | 'blob' | 'text' } & Record<string, any>
) => {
Expand Down
6 changes: 3 additions & 3 deletions packages/web-runtime/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"@uppy/tus": "^3.0.1",
"@uppy/xhr-upload": "^3.0.1",
"@vue/composition-api": "^1.6.2",
"axios": "^0.27.1",
"axios": "^0.27.2",
"cross-fetch": "^3.0.6",
"easygettext": "https://github.com/owncloud/easygettext/archive/refs/tags/v2.18.1-oc.tar.gz",
"filesize": "^9.0.11",
Expand All @@ -31,7 +31,7 @@
"portal-vue": "^2.1.7",
"postcss-import": "^12.0.1",
"postcss-url": "^9.0.0",
"promise": "^8.0.3",
"promise": "^8.1.0",
"qs": "^6.10.3",
"sanitize-html": "^2.7.0",
"semver": "^7.3.7",
Expand All @@ -54,7 +54,7 @@
"vuex-extensions": "^1.1.5",
"vuex-router-sync": "^5.0.0",
"web-pkg": "*",
"webdav": "4.10.0",
"webdav": "^4.10.0",
"webfontloader": "^1.6.28",
"xml-js": "^1.6.11"
},
Expand Down
12 changes: 6 additions & 6 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3509,7 +3509,7 @@ __metadata:
languageName: node
linkType: hard

"axios@npm:^0.27.1, axios@npm:^0.27.2":
"axios@npm:^0.27.2":
version: 0.27.2
resolution: "axios@npm:0.27.2"
dependencies:
Expand Down Expand Up @@ -10815,7 +10815,7 @@ __metadata:
languageName: node
linkType: hard

"promise@npm:^8.0.3":
"promise@npm:^8.1.0":
version: 8.1.0
resolution: "promise@npm:8.1.0"
dependencies:
Expand Down Expand Up @@ -13662,7 +13662,7 @@ __metadata:
"@uppy/tus": ^3.0.1
"@uppy/xhr-upload": ^3.0.1
"@vue/composition-api": ^1.6.2
axios: ^0.27.1
axios: ^0.27.2
cross-fetch: ^3.0.6
easygettext: "https://github.com/owncloud/easygettext/archive/refs/tags/v2.18.1-oc.tar.gz"
filesize: ^9.0.11
Expand All @@ -13680,7 +13680,7 @@ __metadata:
portal-vue: ^2.1.7
postcss-import: ^12.0.1
postcss-url: ^9.0.0
promise: ^8.0.3
promise: ^8.1.0
qs: ^6.10.3
sanitize-html: ^2.7.0
semver: ^7.3.7
Expand All @@ -13703,13 +13703,13 @@ __metadata:
vuex-extensions: ^1.1.5
vuex-router-sync: ^5.0.0
web-pkg: "*"
webdav: 4.10.0
webdav: ^4.10.0
webfontloader: ^1.6.28
xml-js: ^1.6.11
languageName: unknown
linkType: soft

"webdav@npm:4.10.0":
"webdav@npm:^4.10.0":
version: 4.10.0
resolution: "webdav@npm:4.10.0"
dependencies:
Expand Down

0 comments on commit fac384a

Please sign in to comment.