Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to directories 5.0.0 and opendal 0.30.5 #1716

Merged
merged 3 commits into from
Apr 24, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
33 changes: 17 additions & 16 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ bincode = "1"
blake3 = "1"
byteorder = "1.0"
bytes = "1"
opendal = { version= "0.27.1", optional=true }
opendal = { version= "0.30.5", optional=true }
reqsign = {version="0.8.5", optional=true}
clap = { version = "4.1.11", features = ["derive", "env", "wrap_help"] }
directories = "4.0.1"
directories = "5.0.0"
encoding = "0.2"
env_logger = "0.10"
filetime = "0.2"
Expand Down
2 changes: 1 addition & 1 deletion src/cache/azure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ impl AzureBlobCache {
builder.container(container);
builder.root(key_prefix);

let op = Operator::create(builder)?
let op = Operator::new(builder)?
.layer(LoggingLayer::default())
.finish();
Ok(op)
Expand Down
20 changes: 9 additions & 11 deletions src/cache/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -368,12 +368,12 @@ pub trait Storage: Send + Sync {
#[async_trait]
impl Storage for opendal::Operator {
async fn get(&self, key: &str) -> Result<Cache> {
match self.object(&normalize_key(key)).read().await {
match self.read(&normalize_key(key)).await {
Ok(res) => {
let hit = CacheRead::from(io::Cursor::new(res))?;
Ok(Cache::Hit(hit))
}
Err(e) if e.kind() == opendal::ErrorKind::ObjectNotFound => Ok(Cache::Miss),
Err(e) if e.kind() == opendal::ErrorKind::NotFound => Ok(Cache::Miss),
Err(e) => {
warn!("Got unexpected error: {:?}", e);
Ok(Cache::Miss)
Expand All @@ -384,9 +384,7 @@ impl Storage for opendal::Operator {
async fn put(&self, key: &str, entry: CacheWrite) -> Result<Duration> {
let start = std::time::Instant::now();

self.object(&normalize_key(key))
.write(entry.finish()?)
.await?;
self.write(&normalize_key(key), entry.finish()?).await?;

Ok(start.elapsed())
}
Expand All @@ -397,10 +395,10 @@ impl Storage for opendal::Operator {
let path = ".sccache_check";

// Read is required, return error directly if we can't read .
match self.object(path).read().await {
match self.read(path).await {
Ok(_) => (),
// Read not exist file with not found is ok.
Err(err) if err.kind() == ErrorKind::ObjectNotFound => (),
Err(err) if err.kind() == ErrorKind::NotFound => (),
// Tricky Part.
//
// We tolerate rate limited here to make sccache keep running.
Expand All @@ -410,15 +408,15 @@ impl Storage for opendal::Operator {
// and hitting other services rate limit. There are few things we
// can do, so we will print our the error here to make users know
// about it.
Err(err) if err.kind() == ErrorKind::ObjectRateLimited => {
Err(err) if err.kind() == ErrorKind::RateLimited => {
eprintln!("cache storage read check: {err:?}, but we decide to keep running")
}
Err(err) => bail!("cache storage failed to read: {:?}", err),
};

let can_write = match self.object(path).write("Hello, World!").await {
let can_write = match self.write(path, "Hello, World!").await {
Ok(_) => true,
Err(err) if err.kind() == ErrorKind::ObjectAlreadyExists => true,
Err(err) if err.kind() == ErrorKind::AlreadyExists => true,
// Toralte all other write errors because we can do read as least.
Err(err) => {
eprintln!("storage write check failed: {err:?}");
Expand All @@ -438,7 +436,7 @@ impl Storage for opendal::Operator {
}

fn location(&self) -> String {
let meta = self.metadata();
let meta = self.info();
format!(
"{}, name: {}, prefix: {}",
meta.scheme(),
Expand Down
2 changes: 1 addition & 1 deletion src/cache/gcs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ impl GCSCache {
}
builder.signer(signer_builder.build()?);

let op = Operator::create(builder)?
let op = Operator::new(builder)?
.layer(LoggingLayer::default())
.finish();
Ok(op)
Expand Down
2 changes: 1 addition & 1 deletion src/cache/gha.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ impl GHACache {
builder.version(&format!("sccache-v{VERSION}-{version}"));
}

let op = Operator::create(builder)?
let op = Operator::new(builder)?
.layer(LoggingLayer::default())
.finish();
Ok(op)
Expand Down
2 changes: 1 addition & 1 deletion src/cache/memcached.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ impl MemcachedCache {
builder.endpoint(url);
builder.default_ttl(Duration::from_secs(expiration as u64));

let op = Operator::create(builder)?
let op = Operator::new(builder)?
.layer(LoggingLayer::default())
.finish();
Ok(op)
Expand Down
2 changes: 1 addition & 1 deletion src/cache/redis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ impl RedisCache {
.map(|v| v.parse().unwrap_or_default())
.unwrap_or_default());

let op = Operator::create(builder)?
let op = Operator::new(builder)?
.layer(LoggingLayer::default())
.finish();
Ok(op)
Expand Down
2 changes: 1 addition & 1 deletion src/cache/s3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ impl S3Cache {
builder.endpoint(&endpoint_resolver(endpoint, use_ssl)?);
}

let op = Operator::create(builder)?
let op = Operator::new(builder)?
.layer(LoggingLayer::default())
.finish();
Ok(op)
Expand Down
2 changes: 1 addition & 1 deletion src/cache/webdav.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ impl WebdavCache {
builder.endpoint(endpoint);
builder.root(key_prefix);

let op = Operator::create(builder)?
let op = Operator::new(builder)?
.layer(LoggingLayer::default())
.finish();
Ok(op)
Expand Down