Skip to content

Commit

Permalink
Fix ZIO usage mistake
Browse files Browse the repository at this point in the history
  • Loading branch information
dacr committed Sep 1, 2024
1 parent 3ef6747 commit 701de91
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ object PhotoOperations {

def readDrewMetadata(filePath: Path): IO[PhotoFileIssue, Metadata] = {
ZIO
.attemptBlockingIO(ImageMetadataReader.readMetadata(filePath.toFile))
.attemptBlocking(ImageMetadataReader.readMetadata(filePath.toFile))
.mapError(exception => PhotoFileIssue(s"Couldn't read image meta data in file", filePath, exception))
}

Expand Down Expand Up @@ -105,7 +105,7 @@ object PhotoOperations {

def getOriginalFileLastModified(original: Original): IO[PhotoFileIssue, OffsetDateTime] = {
ZIO
.attemptBlockingIO(original.path.toFile.lastModified())
.attemptBlocking(original.path.toFile.lastModified())
.mapAttempt(Instant.ofEpochMilli)
.mapAttempt(_.atZone(ZoneId.systemDefault()).toOffsetDateTime)
.mapError(exception => PhotoFileIssue(s"Unable to get file last modified", original.path, exception))
Expand Down Expand Up @@ -232,7 +232,7 @@ object PhotoOperations {
private def buildPhotoSource(photoId: PhotoId, original: Original): ZIO[PhotoStoreService, PhotoFileIssue, PhotoSource] = {
for {
fileSize <- ZIO
.attemptBlockingIO(original.path.toFile.length())
.attemptBlocking(original.path.toFile.length())
.mapError(exception => PhotoFileIssue(s"Unable to read file size", original.path, exception))
fileLastModified <- getOriginalFileLastModified(original)
fileHash <- PhotoStoreService
Expand All @@ -241,7 +241,7 @@ object PhotoOperations {
.some
.orElse(
ZIO
.attemptBlockingIO(HashOperations.fileDigest(original.path))
.attemptBlocking(HashOperations.fileDigest(original.path))
.mapError(exception => PhotoFileIssue(s"Unable to compute file hash", original.path, exception))
)
} yield PhotoSource(
Expand Down

0 comments on commit 701de91

Please sign in to comment.