mirror of
https://github.com/enso-org/enso.git
synced 2024-12-22 18:01:38 +03:00
parent
0302670092
commit
0399a4570d
@ -7,6 +7,13 @@
|
|||||||
|
|
||||||
[11151]: https://github.com/enso-org/enso/pull/11151
|
[11151]: https://github.com/enso-org/enso/pull/11151
|
||||||
|
|
||||||
|
#### Enso Standard Library
|
||||||
|
|
||||||
|
- [The `enso://~` path now resolves to user's home directory in the
|
||||||
|
cloud.][11235]
|
||||||
|
|
||||||
|
[11235]: https://github.com/enso-org/enso/pull/11235
|
||||||
|
|
||||||
# Enso 2024.4
|
# Enso 2024.4
|
||||||
|
|
||||||
#### Enso IDE
|
#### Enso IDE
|
||||||
|
@ -53,19 +53,6 @@ type Enso_File
|
|||||||
|
|
||||||
Arguments:
|
Arguments:
|
||||||
- path: The `enso://` path to a file or directory.
|
- path: The `enso://` path to a file or directory.
|
||||||
|
|
||||||
? Enso Cloud Paths
|
|
||||||
|
|
||||||
The paths consist of the organization (user) name followed by a path to
|
|
||||||
the file/directory delimited by `/`.
|
|
||||||
For example `enso://my_org/some_dir/some-file.txt`.
|
|
||||||
|
|
||||||
! Work in progress - only existing resources
|
|
||||||
|
|
||||||
Currently the API is only able to resolve paths to existing files or
|
|
||||||
directories. This is a temporary limitation and it will be improved in
|
|
||||||
the future, alongside with implementing the capabilities to write new
|
|
||||||
files.
|
|
||||||
new : Text -> Enso_File ! Not_Found
|
new : Text -> Enso_File ! Not_Found
|
||||||
new (path : Text) =
|
new (path : Text) =
|
||||||
Enso_File.Value (Enso_Path.parse path)
|
Enso_File.Value (Enso_Path.parse path)
|
||||||
@ -77,7 +64,7 @@ type Enso_File
|
|||||||
Represents the current user's home directory.
|
Represents the current user's home directory.
|
||||||
home : Enso_File
|
home : Enso_File
|
||||||
home -> Enso_File =
|
home -> Enso_File =
|
||||||
Enso_File.root / "Users" / Enso_User.current.name
|
Enso_File.root / "Users" / Enso_User.current.name
|
||||||
|
|
||||||
|
|
||||||
## ICON folder
|
## ICON folder
|
||||||
|
@ -63,4 +63,12 @@ type Enso_Path
|
|||||||
|
|
||||||
## PRIVATE
|
## PRIVATE
|
||||||
normalize segments =
|
normalize segments =
|
||||||
Path_Helpers.normalize_segments segments (x->x)
|
after_resolving_dots = Path_Helpers.normalize_segments segments (x->x)
|
||||||
|
starts_with_tilde = after_resolving_dots.take 1 == ["~"]
|
||||||
|
if starts_with_tilde.not then after_resolving_dots else
|
||||||
|
# If after resolution our path starts with `~`, we replace that with a home directory.
|
||||||
|
home_path = Enso_File.home.enso_path
|
||||||
|
new_segments = home_path.path_segments + after_resolving_dots.drop 1
|
||||||
|
## We need to call normalize again, because technically a path `enso://a/../~/../../~` is a valid path
|
||||||
|
that points to the user home and it should be correctly normalized, but requires numerous passes to do so.
|
||||||
|
@Tail_Call normalize new_segments
|
||||||
|
@ -4,6 +4,7 @@ from Standard.Base import all
|
|||||||
import Standard.Base.Enso_Cloud.Data_Link.Data_Link
|
import Standard.Base.Enso_Cloud.Data_Link.Data_Link
|
||||||
import Standard.Base.Errors.File_Error.File_Error
|
import Standard.Base.Errors.File_Error.File_Error
|
||||||
import Standard.Base.Errors.Illegal_Argument.Illegal_Argument
|
import Standard.Base.Errors.Illegal_Argument.Illegal_Argument
|
||||||
|
import Standard.Base.Errors.Illegal_State.Illegal_State
|
||||||
import Standard.Base.Runtime.Context
|
import Standard.Base.Runtime.Context
|
||||||
from Standard.Base.Enso_Cloud.Data_Link_Helpers import data_link_extension, secure_value_to_json
|
from Standard.Base.Enso_Cloud.Data_Link_Helpers import data_link_extension, secure_value_to_json
|
||||||
|
|
||||||
@ -53,7 +54,7 @@ prepare_credentials data_link_location:Enso_File details:Postgres -> JS_Object |
|
|||||||
secret_password = case credentials.password of
|
secret_password = case credentials.password of
|
||||||
secret : Enso_Secret -> secret
|
secret : Enso_Secret -> secret
|
||||||
plain_text_password : Text ->
|
plain_text_password : Text ->
|
||||||
secret_location = data_link_location.parent.if_nothing Enso_File.root
|
secret_location = data_link_location.parent.if_nothing (Error.throw (Illegal_State.Error "Trying to create a secret to store the Data Link password, but the provided data link location: "+data_link_location.to_text+" does not have a parent directory. This should not happen."))
|
||||||
location_name = if data_link_location.name.ends_with data_link_extension then data_link_location.name.drop (..Last data_link_extension.length) else data_link_location.name
|
location_name = if data_link_location.name.ends_with data_link_extension then data_link_location.name.drop (..Last data_link_extension.length) else data_link_location.name
|
||||||
|
|
||||||
create_fresh_secret ix =
|
create_fresh_secret ix =
|
||||||
|
@ -42,7 +42,7 @@ type Temporary_Enso_Cloud_File
|
|||||||
Value ~get
|
Value ~get
|
||||||
|
|
||||||
make tmp_dir_name name = Temporary_Enso_Cloud_File.Value <|
|
make tmp_dir_name name = Temporary_Enso_Cloud_File.Value <|
|
||||||
location = Enso_File.root / tmp_dir_name
|
location = Enso_File.home / tmp_dir_name
|
||||||
Panic.rethrow <| location.create_directory
|
Panic.rethrow <| location.create_directory
|
||||||
location / ("cloud-"+name)
|
location / ("cloud-"+name)
|
||||||
|
|
||||||
|
@ -270,6 +270,21 @@ add_specs suite_builder setup:Cloud_Tests_Setup = suite_builder.group "Enso Clou
|
|||||||
r.should_fail_with Illegal_Argument
|
r.should_fail_with Illegal_Argument
|
||||||
r.catch.to_display_text . should_contain "Cannot move above root"
|
r.catch.to_display_text . should_contain "Cannot move above root"
|
||||||
|
|
||||||
|
group_builder.specify "resolves ~ to user home" <|
|
||||||
|
Enso_File.new "enso://~" . should_equal Enso_File.home
|
||||||
|
Enso_File.new "enso://~/a/b/c" . should_equal (Enso_File.home / "a/b/c")
|
||||||
|
|
||||||
|
# It also works when resolving a path
|
||||||
|
(Enso_File.root / "~") . should_equal Enso_File.home
|
||||||
|
(Enso_File.root / "a/../~/b/c") . should_equal (Enso_File.home / "b/c")
|
||||||
|
Enso_File.new "enso://a/../~/b/c" . should_equal (Enso_File.home / "b/c")
|
||||||
|
|
||||||
|
# But a filename only containing ~ is not resolved
|
||||||
|
Enso_File.new "enso://~~~" . should_not_equal Enso_File.home
|
||||||
|
|
||||||
|
# If the `~` is not at the beginning, it is not resolved
|
||||||
|
Enso_File.new "enso://a/b/c/~" . should_not_equal Enso_File.home
|
||||||
|
|
||||||
group_builder.specify "currently does not support metadata for directories" <|
|
group_builder.specify "currently does not support metadata for directories" <|
|
||||||
# TODO this test should be 'reversed' and merged with above once the metadata is implemented
|
# TODO this test should be 'reversed' and merged with above once the metadata is implemented
|
||||||
dir = test_root.get / "test-directory"
|
dir = test_root.get / "test-directory"
|
||||||
|
@ -34,7 +34,7 @@ add_specs suite_builder prefix ~datalink_to_connection database_pending =
|
|||||||
|
|
||||||
# Retrying is needed as there may be some delay before the background thread finishes processing the logs.
|
# Retrying is needed as there may be some delay before the background thread finishes processing the logs.
|
||||||
Test.with_retries <|
|
Test.with_retries <|
|
||||||
Thread.sleep 500
|
Thread.sleep 1000
|
||||||
all_events = get_audit_log_events
|
all_events = get_audit_log_events
|
||||||
relevant_events = all_events.filter e-> e.message.contains table_name
|
relevant_events = all_events.filter e-> e.message.contains table_name
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user