| author | |
| committer | |
| log | c87873b304450f3f0b1fea2bcf63ba59af51b869 |
| tree | 32f5a64d5373499c700131cfa8ada347c2c6acd1 |
| parent | eb8d89d397b222c147975b63bb30fcc8fd959468 |
| signature | Signed by SSH key SHA256:52mNGHRsVFBDED9IAX5pe+LRWUefqTbxEReunq21QvU |
Copyparty 1.20.26 replies "users, volumes, and volflags have been reloaded", so every share save was reported as unconfirmed and rolled back. New shares now reuse an existing folder instead of failing, and the create-folder checkbox is gone.
Assisted-by: claude-opus-5.54 files changed, 21 insertions(+), 20 deletions(-)
dashboard/web/api.contract.ts+1-1| ... | ... | @@ -68,7 +68,7 @@ export type Api = Hono<{}, { |
| 68 | 68 | $patch: Endpoint<ShareState, { param: { id: string }; json: Omit<FolderGrant, "id"> }>; |
| 69 | 69 | $delete: Endpoint<ShareState, { param: { id: string } }>; |
| 70 | 70 | }; |
| 71 | "/shares/links": { $post: Endpoint<ShareState, { json: LinkInput & { createFolder: boolean } }>; }; | |
| 71 | "/shares/links": { $post: Endpoint<ShareState, { json: LinkInput }>; }; | |
| 72 | 72 | "/shares/links/:key": { |
| 73 | 73 | $patch: Endpoint<ShareState, { param: { key: string }; json: LinkInput & { mode: "retarget" | "move" } }>; |
| 74 | 74 | $delete: Endpoint<ShareState, { param: { key: string } }>; |
dashboard/web/pages/Shares.tsx+4-6| ... | ... | @@ -31,7 +31,7 @@ function Rights(props: { value: string; onChange: (value: string) => void; link? |
| 31 | 31 | </div></fieldset>; |
| 32 | 32 | } |
| 33 | 33 | |
| 34 | function FolderField(props: { value: string; root: string; create?: boolean; onChange: (value: string, existing?: boolean) => void }) { | |
| 34 | function FolderField(props: { value: string; root: string; create?: boolean; onChange: (value: string) => void }) { | |
| 35 | 35 | const browse = () => { |
| 36 | 36 | const [path, setPath] = createSignal(props.create && !props.value.endsWith("/") ? props.value.replace(/\/[^/]+$/, "") || props.root : props.value || props.root); |
| 37 | 37 | showConfirmDialog({ |
| ... | ... | @@ -49,7 +49,7 @@ function FolderField(props: { value: string; root: string; create?: boolean; onC |
| 49 | 49 | </Loaded> |
| 50 | 50 | </div>; |
| 51 | 51 | }, |
| 52 | onConfirm: () => props.onChange(macPath(path(), props.root), true), | |
| 52 | onConfirm: () => props.onChange(macPath(path(), props.root)), | |
| 53 | 53 | }); |
| 54 | 54 | }; |
| 55 | 55 | return <div class="field">folder<div class="share-folder-field"> |
| ... | ... | @@ -244,7 +244,6 @@ function LinkForm(props: { original?: SharedLink; fresh: boolean; state: ShareSt |
| 244 | 244 | const [customPath, setCustomPath] = createSignal(""); |
| 245 | 245 | const path = () => customPath() || `${macPath(props.state.defaultRoot, props.state.root)}/${name().trim()}`; |
| 246 | 246 | const [rights, setRights] = createSignal(props.original?.permissions ?? "r"); |
| 247 | const [createFolder, setCreateFolder] = createSignal(true); | |
| 248 | 247 | const [password, setPassword] = createSignal<string | null>(null); |
| 249 | 248 | const dateValue = (seconds: number) => { |
| 250 | 249 | const date = new Date(seconds * 1000); |
| ... | ... | @@ -261,7 +260,7 @@ function LinkForm(props: { original?: SharedLink; fresh: boolean; state: ShareSt |
| 261 | 260 | const json = { name: name().trim(), path: props.original?.path ?? path(), permissions: rights(), expires: expires() ? new Date(expires()).getTime() / 1000 : 0, password: password() }; |
| 262 | 261 | const result = await parseResponse(props.original |
| 263 | 262 | ? api.shares.links[":key"].$patch({ param: { key: props.original.key }, json: { ...json, mode: "retarget" } }) |
| 264 | : api.shares.links.$post({ json: { ...json, createFolder: createFolder() } })); | |
| 263 | : api.shares.links.$post({ json })); | |
| 265 | 264 | const key = props.original?.key ?? result.links.find((link) => !props.state.links.some((old) => old.key === link.key))?.key; |
| 266 | 265 | if (key) props.saved(result, key); |
| 267 | 266 | setPassword(null); |
| ... | ... | @@ -300,8 +299,7 @@ function LinkForm(props: { original?: SharedLink; fresh: boolean; state: ShareSt |
| 300 | 299 | <fieldset disabled={pending()}> |
| 301 | 300 | <label class="field">name<input class="search" required value={name()} placeholder="Name - Description" autocomplete="off" onInput={(event) => setName(event.currentTarget.value)} /></label> |
| 302 | 301 | <Show when={props.fresh} fallback={<div class="field">folder<div class="share-current-folder"><span class="share-path">{macPath(props.original!.path, props.state.root)}</span><button type="button" class="button" onClick={changeFolder}>change folder</button></div></div>}> |
| 303 | <FolderField value={path()} root={props.state.root} create={createFolder()} onChange={(value, existing) => { setCustomPath(value); if (existing) setCreateFolder(false); }} /> | |
| 304 | <Checkbox checked={createFolder()} onChange={setCreateFolder}>create this folder</Checkbox> | |
| 302 | <FolderField value={path()} root={props.state.root} create onChange={setCustomPath} /> | |
| 305 | 303 | </Show> |
| 306 | 304 | <Show when={props.original?.files.length}><div class="field">selected files<ul class="share-selection"><For each={props.original?.files}>{(file) => <li>{file}</li>}</For></ul><span class="hint">This share keeps its file selection when its folder changes</span></div></Show> |
| 307 | 305 | <Rights value={rights()} onChange={setRights} link /> |
service/copyparty/manage.py+6-11| ... | ... | @@ -24,7 +24,7 @@ ACTIONS = { |
| 24 | 24 | 'account.create': {'name'}, 'account.update': {'id', 'name'}, |
| 25 | 25 | 'account.rotate': {'id'}, 'account.delete': {'id'}, |
| 26 | 26 | 'grant.save': {'id', 'subject', 'path', 'permissions'}, 'grant.delete': {'id'}, |
| 27 | 'link.create': {'name', 'path', 'permissions', 'expires', 'password', 'createFolder'}, | |
| 27 | 'link.create': {'name', 'path', 'permissions', 'expires', 'password'}, | |
| 28 | 28 | 'link.update': {'key', 'name', 'path', 'permissions', 'expires', 'password', 'mode'}, |
| 29 | 29 | 'link.delete': {'key'}, |
| 30 | 30 | } |
| ... | ... | @@ -285,7 +285,7 @@ class Manager: |
| 285 | 285 | try: |
| 286 | 286 | with urllib.request.urlopen(request, timeout=remaining(deadline, 30)) as response: |
| 287 | 287 | body = response.read(262144) |
| 288 | if response.status != 200 or b'config has been reloaded' not in body: | |
| 288 | if response.status != 200 or b'have been reloaded' not in body: | |
| 289 | 289 | raise Error(502, 'Copyparty did not confirm the update. Try again after checking the service.') |
| 290 | 290 | except (urllib.error.URLError, TimeoutError): |
| 291 | 291 | raise Error(502, 'Copyparty could not apply the update. Check the service and try again.') from None |
| ... | ... | @@ -441,9 +441,7 @@ class Manager: |
| 441 | 441 | password = old[1] if old is not None else '' |
| 442 | 442 | else: |
| 443 | 443 | password = self.hash(password) |
| 444 | create = action == 'link.create' and payload['createFolder'] is True | |
| 445 | if action == 'link.create' and type(payload['createFolder']) is not bool: | |
| 446 | raise Error(400, 'Choose an existing folder or create a new one.') | |
| 444 | create = action == 'link.create' | |
| 447 | 445 | destination = payload['path'] |
| 448 | 446 | share_root = self.root / 'Share' |
| 449 | 447 | if create and (not destination or Path(destination).parent == share_root or str(destination).startswith('/Volumes/clover/Share/')): |
| ... | ... | @@ -461,12 +459,9 @@ class Manager: |
| 461 | 459 | mode = payload.get('mode', 'retarget') |
| 462 | 460 | if mode not in {'retarget', 'move'}: |
| 463 | 461 | raise Error(400, 'Choose whether to move the folder or use another folder.') |
| 464 | if create: | |
| 465 | try: | |
| 466 | destination.mkdir(mode=0o775) | |
| 467 | destination.chmod(0o775) | |
| 468 | except FileExistsError: | |
| 469 | raise Error(409, 'That folder already exists. Choose it as an existing folder or change its name.') from None | |
| 462 | if create and not destination.exists(): | |
| 463 | destination.mkdir(mode=0o775) | |
| 464 | destination.chmod(0o775) | |
| 470 | 465 | owner = destination.parent.stat() |
| 471 | 466 | os.chown(destination, owner.st_uid, owner.st_gid) |
| 472 | 467 | self.undo.append(lambda: destination.rmdir()) |
tools/copyparty-test.py+10-2| ... | ... | @@ -174,13 +174,21 @@ class Shares(unittest.TestCase): |
| 174 | 174 | self.assertEqual(self.call('state')['links'][0]['path'], str(destination)) |
| 175 | 175 | |
| 176 | 176 | def test_default_folder_create_and_link_delete_keep_data(self): |
| 177 | result = self.call('link.create', name='Clover - Example', path='', permissions='rw', expires=0, password='', createFolder=True) | |
| 177 | result = self.call('link.create', name='Clover - Example', path='', permissions='rw', expires=0, password='') | |
| 178 | 178 | path = self.root / 'Share/Clover - Example' |
| 179 | 179 | self.assertTrue(path.is_dir()) |
| 180 | 180 | self.call('link.delete', key=result['links'][0]['key']) |
| 181 | 181 | self.assertTrue(path.is_dir()) |
| 182 | 182 | self.assertEqual(self.call('state')['links'], []) |
| 183 | 183 | |
| 184 | def test_link_create_reuses_existing_folder(self): | |
| 185 | path = self.root / 'Share/Clover - Existing' | |
| 186 | path.mkdir(parents=True) | |
| 187 | (path / 'kept.txt').write_text('disposable') | |
| 188 | self.call('link.create', name='Clover - Existing', path='', permissions='r', expires=0, password='') | |
| 189 | self.assertEqual(self.call('state')['links'][0]['path'], str(path)) | |
| 190 | self.assertTrue((path / 'kept.txt').is_file()) | |
| 191 | ||
| 184 | 192 | def test_move_preserves_key_selection_nested_links_and_grants(self): |
| 185 | 193 | source = self.root / 'source' |
| 186 | 194 | (source / 'nested').mkdir(parents=True) |
| ... | ... | @@ -259,7 +267,7 @@ class Shares(unittest.TestCase): |
| 259 | 267 | previous = os.umask(0o077) |
| 260 | 268 | try: |
| 261 | 269 | self.call('link.create', name='Clover - Restricted', path=str(self.root / 'Share/Clover - Restricted'), |
| 262 | permissions='r', expires=0, password='', createFolder=True) | |
| 270 | permissions='r', expires=0, password='') | |
| 263 | 271 | finally: |
| 264 | 272 | os.umask(previous) |
| 265 | 273 | self.assertEqual((self.root / 'Share').stat().st_mode & 0o777, 0o775) |