Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Overwrite content in collection when same fullPath #727

Merged
merged 12 commits into from
Jan 4, 2023

Conversation

gmelodie
Copy link
Contributor

@gmelodie gmelodie commented Dec 9, 2022

Now if you specify overwrite=true it will replace the file with the same name on the collection, and it'll error out if you try doing so without the flag.

Fixes #436

@gmelodie gmelodie requested review from anjor and en0ma December 9, 2022 13:58
@gmelodie gmelodie self-assigned this Dec 9, 2022
@gmelodie gmelodie requested a review from snissn December 9, 2022 13:58
@en0ma
Copy link
Contributor

en0ma commented Dec 9, 2022

@gmelodie there are multiple places contents are added to a collection. It would be nice to abstract the add content to collection logic (with the override flag) and use it everywhere

@gmelodie
Copy link
Contributor Author

gmelodie commented Dec 9, 2022

@en0ma done! Can you help testing?

@alvin-reyes
Copy link
Contributor

Let's fix the conflicts.

@anjor
Copy link
Contributor

anjor commented Dec 18, 2022

Oh yes! Let's get this merged please. It will fix one of the rclone tests. See rclone/rclone#5854 (comment)

@gmelodie gmelodie force-pushed the gabe/collection-path-overwrite branch from 1700d3f to fa4d1bf Compare December 19, 2022 12:23
@anjor
Copy link
Contributor

anjor commented Jan 4, 2023

Tested

anjor@seven ~ $ curl http://localhost:3004/collections/ -H "Authorization: Bearer $(cat ~/.estuary_local)" -XPOST -d '{"name":"overwrite test 5", "description":""}' | jq
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   198  100   153  100    45  33663   9900 --:--:-- --:--:-- --:--:--  193k
{
  "createdAt": "2023-01-04T10:37:32.505977Z",
  "uuid": "f028d521-a575-47ad-9ce1-52b47f6c0e13",
  "name": "overwrite test 5",
  "description": "",
  "userId": 1,
  "cid": ""
}
anjor@seven ~ $ coluuid=f028d521-a575-47ad-9ce1-52b47f6c0e13
anjor@seven ~ $ curl "http://localhost:3004/content/add?coluuid=$coluuid&dir=/test" -H "Authorization: Bearer $(cat ~/.estuary_local)" -H "Content-Type: multipart/form-data" -F "data=@a" | jq
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   703  100   491  100   212  59623  25743 --:--:-- --:--:-- --:--:--  137k
{
  "cid": "bafkreicshyqmt4kwtgdeiqzpkt74wodvo4jnukbiqqnca7xcta7js7qrjm",
  "retrieval_url": "https://dweb.link/ipfs/bafkreicshyqmt4kwtgdeiqzpkt74wodvo4jnukbiqqnca7xcta7js7qrjm",
  "estuary_retrieval_url": "https://api.estuary.tech/gw/ipfs/bafkreicshyqmt4kwtgdeiqzpkt74wodvo4jnukbiqqnca7xcta7js7qrjm",
  "estuaryId": 9278,
  "providers": [
    "/ip4/192.168.86.28/tcp/6744/p2p/12D3KooWG7it68ksNLmK9SjSBEwTM68NHzgaKHUXcm21DhUAuo2k",
    "/ip4/127.0.0.1/tcp/6744/p2p/12D3KooWG7it68ksNLmK9SjSBEwTM68NHzgaKHUXcm21DhUAuo2k"
  ]
}
anjor@seven ~ $ vim
anjor@seven ~ $ curl "http://localhost:3004/content/add?coluuid=$coluuid&dir=/test" -H "Authorization: Bearer $(cat ~/.estuary_local)" -H "Content-Type: multipart/form-data" -F "data=@a" | jq
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   357  100   145  100   212  35696  52191 --:--:-- --:--:-- --:--:--  348k
{
  "error": {
    "code": 400,
    "reason": "ERR_CONTENT_IN_COLLECTION",
    "details": "file already exists in collection, specify 'overwrite=true' to overwrite"
  }
}
anjor@seven ~ $ curl "http://localhost:3004/content/add?coluuid=$coluuid&dir=/test&overwrite=true" -H "Authorization: Bearer $(cat ~/.estuary_local)" -H "Content-Type: multipart/form-data" -F "data=@a" | jq
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   703  100   491  100   212  68527  29588 --:--:-- --:--:-- --:--:--  171k
{
  "cid": "bafkreicshyqmt4kwtgdeiqzpkt74wodvo4jnukbiqqnca7xcta7js7qrjm",
  "retrieval_url": "https://dweb.link/ipfs/bafkreicshyqmt4kwtgdeiqzpkt74wodvo4jnukbiqqnca7xcta7js7qrjm",
  "estuary_retrieval_url": "https://api.estuary.tech/gw/ipfs/bafkreicshyqmt4kwtgdeiqzpkt74wodvo4jnukbiqqnca7xcta7js7qrjm",
  "estuaryId": 9279,
  "providers": [
    "/ip4/192.168.86.28/tcp/6744/p2p/12D3KooWG7it68ksNLmK9SjSBEwTM68NHzgaKHUXcm21DhUAuo2k",
    "/ip4/127.0.0.1/tcp/6744/p2p/12D3KooWG7it68ksNLmK9SjSBEwTM68NHzgaKHUXcm21DhUAuo2k"
  ]
}
anjor@seven ~ $

@anjor anjor enabled auto-merge (squash) January 4, 2023 10:40
@anjor anjor merged commit 2379783 into dev Jan 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

Successfully merging this pull request may close these issues.

New file doesn't get added to collections
4 participants