perfectsense / gyro

Gyro is a command-line tool for creating, updating, and maintaining cloud infrastructure. Gyro makes infrastructure-as-code possible.
https://gyro.dev
Apache License 2.0
134 stars 7 forks source link

Optimization 5 - Add exists(String file) method to FileBackend #315

Closed beetlebugorg closed 4 years ago

beetlebugorg commented 4 years ago

Optimization 5 - Add exists(String file) method to FileBackend

Some resource implementations use FileBackend to upload data and they need to check if the file exists before hand. On the S3FileBackend implementation existence checking in these resources is implemented by calling openInput and then immediately closing it. The problem is that S3 SDK reads the entire file before closing it. That can get expensive when you're downloading a large file just to check that it exists.

https://github.com/perfectsense/gyro/blob/feature/performance/core/src/main/java/gyro/core/FileBackend.java#L54-L64

FileBackend implementations will need to be updated to use this. See the S3FileBackend implementation below.

https://github.com/perfectsense/gyro-aws-provider/blob/feature/performance/src/main/java/gyro/aws/S3FileBackend.java#L128-L137

sshyub commented 4 years ago

PR: https://github.com/perfectsense/gyro/pull/317