diff options
author | Rutger Broekhoff | 2024-01-24 20:40:44 +0100 |
---|---|---|
committer | Rutger Broekhoff | 2024-01-24 20:40:44 +0100 |
commit | d3f53661d5366306a1cf9ef66fbf02a754cc5c3d (patch) | |
tree | 33ecab4e5b7dbe80516d8336765073ee3de0356b | |
parent | 03b6c1b8817cc8224a12eb7f938cdf53e5b1881d (diff) | |
download | gitolfs3-d3f53661d5366306a1cf9ef66fbf02a754cc5c3d.tar.gz gitolfs3-d3f53661d5366306a1cf9ef66fbf02a754cc5c3d.zip |
Read limit as current, not as limit XD
-rw-r--r-- | server/src/main.rs | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/server/src/main.rs b/server/src/main.rs index d96ac17..db37d14 100644 --- a/server/src/main.rs +++ b/server/src/main.rs | |||
@@ -1043,21 +1043,21 @@ impl DownloadLimiter { | |||
1043 | return Ok(false); | 1043 | return Ok(false); |
1044 | } | 1044 | } |
1045 | self.current += n; | 1045 | self.current += n; |
1046 | self.write_new_limit().await?; | 1046 | self.write_new_count().await?; |
1047 | Ok(true) | 1047 | Ok(true) |
1048 | } | 1048 | } |
1049 | 1049 | ||
1050 | async fn reset(&mut self) { | 1050 | async fn reset(&mut self) { |
1051 | self.current = 0; | 1051 | self.current = 0; |
1052 | if let Err(e) = self.write_new_limit().await { | 1052 | if let Err(e) = self.write_new_count().await { |
1053 | println!("Failed to reset download counter: {e}"); | 1053 | println!("Failed to reset download counter: {e}"); |
1054 | } | 1054 | } |
1055 | } | 1055 | } |
1056 | 1056 | ||
1057 | async fn write_new_limit(&self) -> tokio::io::Result<()> { | 1057 | async fn write_new_count(&self) -> tokio::io::Result<()> { |
1058 | let cwd = tokio::fs::File::open(std::env::current_dir()?).await?; | 1058 | let cwd = tokio::fs::File::open(std::env::current_dir()?).await?; |
1059 | let mut file = tokio::fs::File::create(".gitolfs3-dlimit.tmp").await?; | 1059 | let mut file = tokio::fs::File::create(".gitolfs3-dlimit.tmp").await?; |
1060 | file.write_all(self.limit.to_string().as_bytes()).await?; | 1060 | file.write_all(self.current.to_string().as_bytes()).await?; |
1061 | file.sync_all().await?; | 1061 | file.sync_all().await?; |
1062 | tokio::fs::rename(".gitolfs3-dlimit.tmp", ".gitolfs3-dlimit").await?; | 1062 | tokio::fs::rename(".gitolfs3-dlimit.tmp", ".gitolfs3-dlimit").await?; |
1063 | cwd.sync_all().await | 1063 | cwd.sync_all().await |