-
Notifications
You must be signed in to change notification settings - Fork 317
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow project manager to write files (#9483)
close #9360 Changelog: - add: `--filesystem-write-path {path}` command allowing to write bytes from stdin to the provided path
- Loading branch information
Showing
11 changed files
with
177 additions
and
6 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
50 changes: 50 additions & 0 deletions
50
...in/scala/org/enso/projectmanager/boot/command/filesystem/FileSystemWritePathCommand.scala
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,50 @@ | ||
package org.enso.projectmanager.boot.command.filesystem | ||
|
||
import org.enso.projectmanager.boot.configuration.ProjectManagerConfig | ||
import org.enso.projectmanager.control.core.syntax._ | ||
import org.enso.projectmanager.control.core.{Applicative, CovariantFlatMap} | ||
import org.enso.projectmanager.control.effect.{ErrorChannel, Sync} | ||
import org.enso.projectmanager.infrastructure.file.BlockingFileSystem | ||
import org.enso.projectmanager.infrastructure.random.SystemGenerator | ||
import org.enso.projectmanager.infrastructure.repository.ProjectFileRepositoryFactory | ||
import org.enso.projectmanager.infrastructure.time.RealClock | ||
import org.enso.projectmanager.protocol.FileSystemManagementApi.FileSystemWritePath | ||
import org.enso.projectmanager.service.filesystem.{ | ||
FileSystemService, | ||
FileSystemServiceApi, | ||
FileSystemServiceFailure | ||
} | ||
|
||
import java.io.{File, InputStream} | ||
|
||
final class FileSystemWritePathCommand[F[+_, +_]: CovariantFlatMap]( | ||
service: FileSystemServiceApi[F], | ||
path: File, | ||
data: InputStream | ||
) { | ||
|
||
def run: F[FileSystemServiceFailure, FileSystemWritePath.Result] = | ||
service.write(path, data).map(_ => FileSystemWritePath.Result) | ||
} | ||
|
||
object FileSystemWritePathCommand { | ||
|
||
def apply[F[+_, +_]: Applicative: CovariantFlatMap: ErrorChannel: Sync]( | ||
config: ProjectManagerConfig, | ||
path: File | ||
): FileSystemWritePathCommand[F] = { | ||
val clock = new RealClock[F] | ||
val fileSystem = new BlockingFileSystem[F](config.timeout.ioTimeout) | ||
val gen = new SystemGenerator[F] | ||
val projectRepositoryFactory = new ProjectFileRepositoryFactory[F]( | ||
config.storage, | ||
clock, | ||
fileSystem, | ||
gen | ||
) | ||
|
||
val service = new FileSystemService[F](fileSystem, projectRepositoryFactory) | ||
|
||
new FileSystemWritePathCommand[F](service, path, System.in) | ||
} | ||
} |
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
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