Skip to content

Commit 53be850

Browse files
fix: address FileMint project review findings
1 parent 729ea04 commit 53be850

59 files changed

Lines changed: 1902 additions & 497 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.github/workflows/build-pages.yml‎

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,6 @@ run-name: FileMint site ${{ inputs.request_id || github.sha }}
33
on:
44
push:
55
branches: [main]
6-
paths:
7-
- README.md
8-
- README.zh-CN.md
9-
- website/**
10-
- package.json
11-
- pnpm-lock.yaml
12-
- specs/domains/presentation.md
13-
- specs/domains/distribution.md
14-
- docs/DISTRIBUTION.md
15-
- .github/workflows/build-pages.yml
16-
- .github/workflows/deploy-pages.yml
17-
- .github/workflows/deploy-website.yml
186
workflow_dispatch:
197
inputs:
208
request_id:

‎.github/workflows/deploy-website.yml‎

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: Deploy website-only update
2-
run-name: FileMint website deploy ${{ github.event.workflow_run.head_sha || inputs.commit }}
2+
run-name: ${{ inputs.release_commit && format('FileMint catchup {0}', inputs.request_id) || format('FileMint website deploy {0}', github.event.workflow_run.head_sha || inputs.commit) }}
33
on:
44
workflow_run:
55
workflows: [Build FileMint website]
@@ -9,20 +9,28 @@ on:
99
inputs:
1010
commit:
1111
description: Current main commit containing the website update
12-
required: true
12+
required: false
1313
type: string
1414
build_run_id:
1515
description: Successful main-push Build FileMint website run
16-
required: true
16+
required: false
1717
type: string
1818
artifact_id:
1919
description: Exact unexpired github-pages artifact from that run
20-
required: true
20+
required: false
2121
type: string
2222
release_id:
2323
description: Current published stable Latest application Release ID
2424
required: true
2525
type: string
26+
release_commit:
27+
description: Published release commit for automatic main-push catch-up
28+
required: false
29+
type: string
30+
request_id:
31+
description: Publisher journal request identity for catch-up
32+
required: false
33+
type: string
2634
permissions:
2735
contents: read
2836
actions: read
@@ -65,6 +73,8 @@ jobs:
6573
SITE_BUILD_RUN_ID: ${{ inputs.build_run_id }}
6674
SITE_ARTIFACT_ID: ${{ inputs.artifact_id }}
6775
SITE_RELEASE_ID: ${{ inputs.release_id }}
76+
SITE_RELEASE_COMMIT: ${{ inputs.release_commit }}
77+
SITE_REQUEST_ID: ${{ inputs.request_id }}
6878
run: node website/scripts/prepare-deployment.mjs
6979
- uses: actions/configure-pages@983d7736d9b0ae728b81ab479565c72886d7745b # v5
7080
if: steps.candidate.outputs.ready == 'true'

‎App/FileMint/FileOperationCoordinator.swift‎

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -399,17 +399,19 @@ final class FileOperationCoordinator: NSObject, NSSharingServiceDelegate {
399399
try await TerminalDirectoryLauncher.open(directory, with: application,
400400
applicationURL: applicationURL, mode: mode)
401401

402-
case .resource(let tool, let selection):
402+
case .resource(let tool, let items):
403+
let selection = items.map(\.source)
403404
guard ResourceToolsPolicy.availableTools(selection: selection, isItemMenu: true,
404405
preferences: currentPreferences).contains(tool) else { throw ResourceError.disabled }
405406
var bookmarks: [String: Data] = [:]
406407
guard try authorizeParents(of: selection, bookmarks: &bookmarks, readOnly: true) else { return }
407408
try requireResolvedSelection(selection)
408409
guard ResourceToolsPolicy.availableTools(selection: selection, isItemMenu: true,
409410
preferences: currentPreferences).contains(tool) else { throw ResourceError.disabled }
410-
try await resourceController.present(selection: selection, tool: tool)
411+
try await resourceController.present(selection: selection, tool: tool, expected: items)
411412

412-
case .prepare(let selection):
413+
case .prepare(let items):
414+
let selection = items.map(\.source)
413415
guard FileToolsPolicy.availableTools(selection: selection, isItemMenu: true,
414416
preferences: currentPreferences).contains(.move) else { throw FileMoveError.disabled }
415417
var bookmarks: [String: Data] = [:]
@@ -419,8 +421,8 @@ final class FileOperationCoordinator: NSObject, NSSharingServiceDelegate {
419421
preferences: currentPreferences).contains(.move) else { throw FileMoveError.disabled }
420422
let store = self.store
421423
try await Task.detached(priority: .userInitiated) {
422-
let pending = try PendingFileMove.capture(selection: selection)
423-
try store.save(pending)
424+
let pending = try PendingFileMove.validate(captured: items)
425+
try store.replaceSelection(pending)
424426
}.value
425427

426428
case .permanentDelete(let items, let confirmation):
@@ -701,6 +703,22 @@ final class FileOperationCoordinator: NSObject, NSSharingServiceDelegate {
701703
return
702704
}
703705
if let error = error as? FileMoveError {
706+
if case .restoreBlocked(let staged, let destination) = error {
707+
let alert = NSAlert()
708+
alert.messageText = text(.moveFailed)
709+
alert.informativeText = String(format: text(.moveRestoreBlocked), staged.path, destination.path)
710+
NSApp.activate(ignoringOtherApps: true)
711+
alert.runModal()
712+
return
713+
}
714+
if case .retryDestination(let destination) = error {
715+
let alert = NSAlert()
716+
alert.messageText = text(.moveFailed)
717+
alert.informativeText = String(format: text(.moveRetryDestination), destination.path)
718+
NSApp.activate(ignoringOtherApps: true)
719+
alert.runModal()
720+
return
721+
}
704722
if let recovery = error.recoveryURL {
705723
let alert = NSAlert()
706724
alert.messageText = text(.moveFailed)
@@ -712,6 +730,10 @@ final class FileOperationCoordinator: NSObject, NSSharingServiceDelegate {
712730
let key: FileMintTextKey = switch error {
713731
case .invalidSelection: .moveInvalidSelection
714732
case .sourceChanged: .moveSourceChanged
733+
case .copiedSourceRetained: .moveCopiedSourceRetained
734+
case .retryDestination: .moveRetryDestination
735+
case .restoreBlocked: .moveRestoreBlocked
736+
case .sourceRestored: .moveSourceRestored
715737
case .invalidDestination: .moveInvalidDestination
716738
case .destinationExists: .moveDestinationExists
717739
case .staleRequest: .moveStaleRequest

0 commit comments

Comments
 (0)