diff --git a/ocis/pkg/command/shares.go b/ocis/pkg/command/shares.go index 2cfb8d10bdf..a66f7bb489c 100644 --- a/ocis/pkg/command/shares.go +++ b/ocis/pkg/command/shares.go @@ -143,8 +143,10 @@ func cleanup(c *cli.Context, cfg *config.Config) error { // │ └── a9/a5/4c/e7/-de30-4d27-94f8-10e4612c66c2.mpk (Phase 3: parent node for ancestry lookup) // │ {"user.ocis.name": "einstein", "user.ocis.id": "a9a54ce7-...", "user.ocis.parentid": "...users-node-id..."} // └── uploads/ (rootMetadataUploads) -// └── d702d7e1-37b0-4d41-b8dc-4b90c1d1f907 (Phase 1: read .json blob for Shares data; blobUploadsPath = filepath.Join(rootMetadataUploads, blobID)) -// {"Shares": {"215fee7a-...:480049db-...:84652da9-...": {resource_id: {...}, grantee: {...}, creator: {...}}}} +// ├── d702d7e1-37b0-4d41-b8dc-4b90c1d1f907 (Phase 1: read .json blob for Shares data; blobUploadsPath = filepath.Join(rootMetadataUploads, blobID)) +// │ {"Shares": {"215fee7a-...:480049db-...:84652da9-...": {resource_id: {...}, grantee: {...}, creator: {...}}}} +// └── 1c93b82b-d22d-41e0-8038-5a706e9b409e.info +// {"MetaData": {"dir": "/users/4c510ada-c86b-4815-8820-42cdf82c3d51", "filename": "received.json", ...}, "Storage": {"NodeName": "received.json", "SpaceRoot": "jsoncs3-share-manager-metadata", ...}} func moveStuckUploadBlobsCmd(cfg *config.Config) *cli.Command { return &cli.Command{ @@ -286,11 +288,11 @@ func restoreFromUploads(rootMetadataUploads string, missing map[string]string, d continue } + // Check if the blob exists in the uploads folder and move it to the share manager metadata blobs/ folder if _, err := os.Stat(blobUploadsPath); err != nil { fmt.Printf(" Blob %s: not found in %s\n", blobID, blobUploadsPath) continue } - fmt.Printf(" Move %s to %s\n", blobUploadsPath, blobPathAbs) if err := os.MkdirAll(filepath.Dir(blobPathAbs), 0755); err != nil { fmt.Printf(" Warning: Failed to create dir: %v\n", err) @@ -301,6 +303,17 @@ func restoreFromUploads(rootMetadataUploads string, missing map[string]string, d continue } + // Remove the info file after the blob is moved + infoPath := blobUploadsPath + ".info" + if _, err := os.Stat(infoPath); err != nil { + fmt.Printf(" Info file %s: not found\n", infoPath) + continue + } + if err := os.Remove(infoPath); err != nil { + fmt.Printf(" Warning: Failed to remove info file: %v\n", err) + continue + } + remainingBlobIDs[blobID] = false }