-
Notifications
You must be signed in to change notification settings - Fork 323
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Implements the core parts of #9048 - Currently the path resolution is done by resolving each segment, one by one - requiring as many API calls as there are segments in the path. - This should be replaced in a followup PR, once enso-org/cloud-v2#899 is implemented.
- Loading branch information
Showing
14 changed files
with
146 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
distribution/lib/Standard/Base/0.0.0-dev/src/Enso_Cloud/Enso_User.enso
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
distribution/lib/Standard/Base/0.0.0-dev/src/Enso_Cloud/Internal/Enso_Path.enso
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
private | ||
|
||
import project.Data.Index_Sub_Range.Index_Sub_Range | ||
import project.Data.Text.Text | ||
import project.Data.Vector.Vector | ||
import project.Enso_Cloud.Enso_File.Enso_File | ||
import project.Enso_Cloud.Enso_User.Enso_User | ||
import project.Error.Error | ||
import project.Errors.Illegal_Argument.Illegal_Argument | ||
import project.Errors.Unimplemented.Unimplemented | ||
import project.Nothing.Nothing | ||
from project.Data.Text.Extensions import all | ||
|
||
## PRIVATE | ||
UNSTABLE | ||
This is a temporary helper for resolving `enso://` paths. | ||
It will be replaced once the backend resolver is implemented: https://github.com/enso-org/cloud-v2/issues/899 | ||
type Enso_Path | ||
## PRIVATE | ||
Value (organization_name : Text) (path_segments : Vector Text) (asset_name : Text | Nothing) | ||
|
||
## PRIVATE | ||
parse (path : Text) -> Enso_Path = | ||
prefix = "enso://" | ||
if path.starts_with prefix . not then Error.throw (Illegal_Argument.Error "Invalid path - it should start with `enso://`.") else | ||
raw_segments = path.drop prefix.length . split "/" | ||
if raw_segments.is_empty then Error.throw (Illegal_Argument.Error "Invalid path - it should contain at least one segment.") else | ||
organization_name = raw_segments.first | ||
segments = raw_segments.drop 1 . filter s-> s.is_empty.not | ||
if organization_name != Enso_User.current.name then Error.throw (Unimplemented.throw "Currently only resolving paths for the current user is supported.") else | ||
if segments.is_empty then Enso_Path.Value organization_name [] Nothing else | ||
asset_name = segments.last | ||
Enso_Path.Value organization_name (segments.drop (Index_Sub_Range.Last 1)) asset_name | ||
|
||
## PRIVATE | ||
resolve_parent self = | ||
self.path_segments.fold Enso_File.root (/) |
File renamed without changes.
1 change: 0 additions & 1 deletion
1
distribution/lib/Standard/Base/0.0.0-dev/src/Network/HTTP/Header.enso
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
std-bits/base/src/main/java/org/enso/base/enso_cloud/EnsoPathFileSystemSPI.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package org.enso.base.enso_cloud; | ||
|
||
import org.enso.base.file_system.FileSystemSPI; | ||
|
||
/** | ||
* Registers the `enso://` protocol for resolving file paths. | ||
* | ||
* <p>See `Enso_File.new` for more information on path resolution. | ||
*/ | ||
@org.openide.util.lookup.ServiceProvider(service = FileSystemSPI.class) | ||
public class EnsoPathFileSystemSPI extends FileSystemSPI { | ||
@Override | ||
protected String getModuleName() { | ||
return "Standard.Base.Enso_Cloud.Enso_File"; | ||
} | ||
|
||
@Override | ||
protected String getTypeName() { | ||
return "Enso_File"; | ||
} | ||
|
||
@Override | ||
protected String getProtocol() { | ||
return "enso"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters