Skip to content

Commit

Permalink
method stubs for S3: implementation postponed for #9704
Browse files Browse the repository at this point in the history
  • Loading branch information
radeusgd committed Apr 15, 2024
1 parent 65fb3c0 commit 6180187
Showing 1 changed file with 32 additions and 4 deletions.
36 changes: 32 additions & 4 deletions distribution/lib/Standard/AWS/0.0.0-dev/src/S3/S3_File.enso
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,20 @@ type S3_File
content_length = translate_file_errors self <| S3.raw_head self.s3_path.bucket self.s3_path.key self.credentials . contentLength
if content_length.is_nothing then Error.throw (S3_Error.Error "ContentLength header is missing." self.uri) else content_length

## ICON folder_add
Creates the directory represented by this file if it did not exist.

It also creates parent directories if they did not exist.

? S3 Handling of Directories

S3 does not have a native concept of directories.
TODO: Add more information about how S3 handles directories.
https://github.com/enso-org/enso/issues/9704
create_directory : File
create_directory self =
Unimplemented.throw "Creating S3 folders is currently not implemented."

## PRIVATE
ADVANCED
Creates a new output stream for this file and runs the specified action
Expand Down Expand Up @@ -182,15 +196,29 @@ type S3_File

## ICON data_output
Deletes the object.

Arguments:
- recursive: If the target is a non-empty directory, it will only be
removed if this is set to `True`. Defaults to `False`, meaning that the
operation will fail if the directory is not empty. This option has no
effect for files or data links.
delete : Nothing
delete self = if self.is_directory then Error.throw (S3_Error.Error "Deleting S3 folders is currently not implemented." self.uri) else
if self.exists.not then Error.throw (File_Error.Not_Found self) else
self.delete_if_exists
delete self (recursive : Boolean = False) =
# TODO implement recursive deletion for S3 folders: https://github.com/enso-org/enso/issues/9704
if self.is_directory then Error.throw (S3_Error.Error "Deleting S3 folders is currently not implemented." self.uri) else
if self.exists.not then Error.throw (File_Error.Not_Found self) else
self.delete_if_exists recursive

## ICON data_output
Deletes the file if it had existed.

Arguments:
- recursive: If the target is a non-empty directory, it will only be
removed if this is set to `True`. Defaults to `False`, meaning that the
operation will fail if the directory is not empty. This option has no
effect for files or data links.
delete_if_exists : Nothing
delete_if_exists self = if self.is_directory then Error.throw (S3_Error.Error "Deleting S3 folders is currently not implemented." self.uri) else
delete_if_exists self (recursive : Boolean = False) = if self.is_directory then Error.throw (S3_Error.Error "Deleting S3 folders is currently not implemented." self.uri) else
Context.Output.if_enabled disabled_message="Deleting an S3_File is forbidden as the Output context is disabled." panic=False <|
translate_file_errors self <| S3.delete_object self.s3_path.bucket self.s3_path.key self.credentials . if_not_error Nothing

Expand Down

0 comments on commit 6180187

Please sign in to comment.