-
Notifications
You must be signed in to change notification settings - Fork 117
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
Update ListFiles to return directories and add MakeDir endpoint #4552
Conversation
proto/rill/runtime/v1/api.proto
Outdated
message MakeDirRequest { | ||
string instance_id = 1 [(validate.rules).string = {pattern: "^[_\\-a-zA-Z0-9]+$"}]; | ||
string path = 2 [(validate.rules).string.min_len = 1]; | ||
// Create indicates whether to create the directory if it doesn't already exist | ||
bool create = 3; | ||
// Will cause the operation to fail if the directory already exists. | ||
// It should only be set when create = true. | ||
bool create_only = 4; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
create
and create_only
don't really make sense here. Maybe add ignore_if_exists
if it's needed?
proto/rill/runtime/v1/api.proto
Outdated
rpc MakeDir(MakeDirRequest) returns (MakeDirResponse) { | ||
option (google.api.http) = { | ||
post: "/v1/instances/{instance_id}/files/make-dir/-/{path=**}", | ||
body: "*" | ||
}; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe CreateDirectory
for consistency with other API names?
proto/rill/runtime/v1/api.proto
Outdated
repeated ListFileEntry files = 1; | ||
} | ||
|
||
message ListFileEntry { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this type isn't itself a listing, maybe FileEntry
?
runtime/compilers/rillv1/parser.go
Outdated
var paths []string | ||
for _, file := range files { | ||
if file.IsDir { | ||
continue | ||
} | ||
paths = append(paths, file.Path) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about adding a skipDirs bool
option to ListRecursive
instead? It could be useful and would avoid some allocations.
runtime/drivers/drivers_test.go
Outdated
//withDuckDB, | ||
withFile, | ||
withPostgres, | ||
withSQLite, | ||
//withPostgres, | ||
//withSQLite, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs to be reverted
runtime/drivers/repo.go
Outdated
type FileEntry struct { | ||
Path string | ||
IsDir bool | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we call it DirEntry
to align with Go's type name for it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ya makes sense
proto/rill/runtime/v1/api.proto
Outdated
|
||
rpc CreateDirectory(CreateDirectoryRequest) returns (CreateDirectoryResponse) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a docstring :)
proto/rill/runtime/v1/api.proto
Outdated
@@ -78,6 +78,13 @@ service RuntimeService { | |||
}; | |||
} | |||
|
|||
rpc CreateDirectory(CreateDirectoryRequest) returns (CreateDirectoryResponse) { | |||
option (google.api.http) = { | |||
post: "/v1/instances/{instance_id}/files/make-dir/-/{path=**}", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make-dir
probably needs to be changed
@@ -448,6 +460,15 @@ message PutFileResponse { | |||
string file_path = 1; // TODO: Redundant, should be removed (but frontend currently uses it) | |||
} | |||
|
|||
message CreateDirectoryRequest { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Docstring
bool ignore_if_exists = 3; | ||
} | ||
|
||
message CreateDirectoryResponse {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Docstring
runtime/compilers/rillv1/parser.go
Outdated
var paths []string | ||
for _, file := range files { | ||
paths = append(paths, file.Path) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be removed and files
renamed to paths
(look at the diff vs. main)
runtime/compilers/rillv1/parser.go
Outdated
var paths []string | ||
for _, file := range files { | ||
paths = append(paths, file.Path) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment
runtime/repos.go
Outdated
} | ||
defer release() | ||
|
||
// TODO: Handle ignoreIfExists |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we fix this todo (or remove the ignoreIfExists
option entirely)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ya i think it makes sense to just remove it. Let it error if the folder exists.
@@ -62,14 +70,14 @@ func (s *Server) WatchFiles(req *runtimev1.WatchFilesRequest, ss runtimev1.Runti | |||
defer release() | |||
|
|||
if req.Replay { | |||
paths, err := repo.ListRecursive(ss.Context(), "**") | |||
files, err := repo.ListRecursive(ss.Context(), "**", true) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Won't you need to be told about new/deleted directories in WatchFiles
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have not updated WatchFiles
to include folders just yet. I plan to add it in a follow up.
proto/rill/runtime/v1/api.proto
Outdated
repeated FileEntry files = 1; | ||
} | ||
|
||
message FileEntry { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Add a docstring
- If we're calling it
DirEntry
internally now, we should probably also call it that here to align names
30eda43
to
56d83e8
Compare
To prepare for asset explorer,
MakeDir
for this.Note: We do not need this in watch files as of now, since that is used to react to assets.