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

[Breaking change] change handleGetCollectionContents #341

Merged
merged 2 commits into from
Jul 21, 2022

Conversation

anjor
Copy link
Contributor

@anjor anjor commented Jul 20, 2022

Tested as follows:

Created a collection

anjor@seven ~ $ curl -k http://localhost:3004/collections/create -d '{"name":"test_collections", "description":"testing collections"}' -H "Authorization: Bearer $ESTUARY_TOKEN" | jq .
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   236  100   172  100    64   4646   1728 --:--:-- --:--:-- --:--:--  7612
{
  "createdAt": "2022-07-20T19:57:06.522091Z",
  "uuid": "998d6947-7c3d-417d-bc1d-d5a833d4d6e6",
  "name": "test_collections",
  "description": "testing collections",
  "userId": 1,
  "cid": ""
}

Added file "a" to /test1/test2/test3, and then fetched contents at /, /test1, /test1/test2 and /test1/test2/test3

anjor@seven ~ $ uuid=998d6947-7c3d-417d-bc1d-d5a833d4d6e6
anjor@seven ~ $ curl -XPOST "http://localhost:3004/content/add?coluuid=$uuid&dir=/test1/test2/test3" -H "Authorization: Bearer $ESTUARY_TOKEN" -F 'data=@/Users/anjor/a'
{"cid":"bafkqaarrbi","estuaryId":8,"providers":["/ip4/192.168.86.32/tcp/6744/p2p/12D3KooWEuqadJHhbB1cerfsd5M7u2KSXGJRzhTRmxL3FJEdFeGb","/ip4/127.0.0.1/tcp/6744/p2p/12D3KooWEuqadJHhbB1cerfsd5M7u2KSXGJRzhTRmxL3FJEdFeGb"]}
anjor@seven ~ $ curl "http://localhost:3004/collections/content?coluuid=$uuid&dir=/test1/test2/test3" -H "Authorization: Bearer $ESTUARY_TOKEN"  | jq .
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   141  100   141    0     0  10960      0 --:--:-- --:--:-- --:--:-- 20142
[
  {
    "name": "a",
    "type": "",
    "size": 2,
    "contId": 8,
    "cid": "bafkqaarrbi",
    "dir": "/test1/test2/test3",
    "coluuid": "998d6947-7c3d-417d-bc1d-d5a833d4d6e6"
  }
]
anjor@seven ~ $ curl "http://localhost:3004/collections/content?coluuid=$uuid&dir=/test1/test2" -H "Authorization: Bearer $ESTUARY_TOKEN"  | jq .
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   128  100   128    0     0  11400      0 --:--:-- --:--:-- --:--:-- 25600
[
  {
    "name": "test3",
    "type": "directory",
    "size": 0,
    "contId": 0,
    "dir": "/test1/test2",
    "coluuid": "998d6947-7c3d-417d-bc1d-d5a833d4d6e6"
  }
]
anjor@seven ~ $ curl "http://localhost:3004/collections/content?coluuid=$uuid&dir=/test1" -H "Authorization: Bearer $ESTUARY_TOKEN"  | jq .
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   122  100   122    0     0  10738      0 --:--:-- --:--:-- --:--:-- 24400
[
  {
    "name": "test2",
    "type": "directory",
    "size": 0,
    "contId": 0,
    "dir": "/test1",
    "coluuid": "998d6947-7c3d-417d-bc1d-d5a833d4d6e6"
  }
]
anjor@seven ~ $ curl "http://localhost:3004/collections/content?coluuid=$uuid&dir=/" -H "Authorization: Bearer $ESTUARY_TOKEN"  | jq .
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   117  100   117    0     0  14523      0 --:--:-- --:--:-- --:--:-- 39000
[
  {
    "name": "test1",
    "type": "directory",
    "size": 0,
    "contId": 0,
    "dir": "/",
    "coluuid": "998d6947-7c3d-417d-bc1d-d5a833d4d6e6"
  }
]

Then added a file "b" at /test1/test2, and again fetched contents.

anjor@seven ~ $ curl -XPOST "http://localhost:3004/content/add?coluuid=$uuid&dir=/test1/test2" -H "Authorization: Bearer $ESTUARY_TOKEN" -F 'data=@/Users/anjor/b'
{"cid":"bafkqaarrbi","estuaryId":9,"providers":["/ip4/192.168.86.32/tcp/6744/p2p/12D3KooWEuqadJHhbB1cerfsd5M7u2KSXGJRzhTRmxL3FJEdFeGb","/ip4/127.0.0.1/tcp/6744/p2p/12D3KooWEuqadJHhbB1cerfsd5M7u2KSXGJRzhTRmxL3FJEdFeGb"]}
anjor@seven ~ $ curl "http://localhost:3004/collections/content?coluuid=$uuid&dir=/test1/test2/test3" -H "Authorization: Bearer $ESTUARY_TOKEN"  | jq .
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   141  100   141    0     0  11352      0 --:--:-- --:--:-- --:--:-- 23500
[
  {
    "name": "a",
    "type": "",
    "size": 2,
    "contId": 8,
    "cid": "bafkqaarrbi",
    "dir": "/test1/test2/test3",
    "coluuid": "998d6947-7c3d-417d-bc1d-d5a833d4d6e6"
  }
]
anjor@seven ~ $ curl "http://localhost:3004/collections/content?coluuid=$uuid&dir=/test1/test2" -H "Authorization: Bearer $ESTUARY_TOKEN"  | jq .
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   261  100   261    0     0  23206      0 --:--:-- --:--:-- --:--:-- 65250
[
  {
    "name": "test3",
    "type": "directory",
    "size": 0,
    "contId": 0,
    "dir": "/test1/test2",
    "coluuid": "998d6947-7c3d-417d-bc1d-d5a833d4d6e6"
  },
  {
    "name": "b",
    "type": "",
    "size": 2,
    "contId": 9,
    "cid": "bafkqaarrbi",
    "dir": "/test1/test2",
    "coluuid": "998d6947-7c3d-417d-bc1d-d5a833d4d6e6"
  }
]
anjor@seven ~ $ curl "http://localhost:3004/collections/content?coluuid=$uuid&dir=/test1" -H "Authorization: Bearer $ESTUARY_TOKEN"  | jq .
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   122  100   122    0     0  11236      0 --:--:-- --:--:-- --:--:-- 30500
[
  {
    "name": "test2",
    "type": "directory",
    "size": 0,
    "contId": 0,
    "dir": "/test1",
    "coluuid": "998d6947-7c3d-417d-bc1d-d5a833d4d6e6"
  }
]
anjor@seven ~ $ curl "http://localhost:3004/collections/content?coluuid=$uuid&dir=/" -H "Authorization: Bearer $ESTUARY_TOKEN"  | jq .
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   117  100   117    0     0  12831      0 --:--:-- --:--:-- --:--:-- 58500
[
  {
    "name": "test1",
    "type": "directory",
    "size": 0,
    "contId": 0,
    "dir": "/",
    "coluuid": "998d6947-7c3d-417d-bc1d-d5a833d4d6e6"
  }
]

I think the behaviour is generally what we want. There are a couple of things I still want to work out:

  1. I think the way we handle subDir, there will be an issue if there are subdirectories with the same name, for example /abc/def/def
  2. What exactly is going on with r.Type? I don't think we actually set that when we add content.

Ideally I would at least like to fix (1) in this PR. We can handle (2) separately.
on second thoughts, would like to merge this as soon as possible.

@anjor anjor changed the title change handleGetCollectionContents [Breaking change] change handleGetCollectionContents Jul 20, 2022
@anjor
Copy link
Contributor Author

anjor commented Jul 21, 2022

handlers.go Show resolved Hide resolved
handlers.go Show resolved Hide resolved
handlers.go Show resolved Hide resolved
@anjor anjor merged commit 0b19941 into master Jul 21, 2022
@en0ma en0ma deleted the anjor/collection-response-change branch July 28, 2022 07:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants