[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [ooni-probe/master] Bugfixes to quota management



commit e6b6f023681bd4e04efa7eb896f2daf9291451ef
Author: Arturo Filastò <arturo@xxxxxxxxxxx>
Date:   Mon Sep 5 18:32:45 2016 +0200

    Bugfixes to quota management
---
 ooni/agent/scheduler.py | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/ooni/agent/scheduler.py b/ooni/agent/scheduler.py
index 3cbd29d..21dd1cd 100644
--- a/ooni/agent/scheduler.py
+++ b/ooni/agent/scheduler.py
@@ -176,13 +176,13 @@ class CheckMeasurementQuota(ScheduledTask):
         if config.basic.measurement_quota is None:
             return
         maximum_bytes = human_size_to_bytes(config.basic.measurement_quota)
-        available_bytes = directory_usage(config.measurements_directory)
+        used_bytes = directory_usage(config.measurements_directory)
         warning_path = os.path.join(config.running_path, 'quota_warning')
 
-        if (float(available_bytes) / float(maximum_bytes)) >= self._warn_when:
+        if (float(used_bytes) / float(maximum_bytes)) >= self._warn_when:
             log.warn("You are about to reach the maximum allowed quota. Be careful")
             with open(warning_path, "w") as out_file:
-                out_file.write("{0} {1}".format(available_bytes,
+                out_file.write("{0} {1}".format(used_bytes,
                                                 maximum_bytes))
         else:
             try:
@@ -191,12 +191,12 @@ class CheckMeasurementQuota(ScheduledTask):
                 if ose.errno != errno.ENOENT:
                     raise
 
-        if float(available_bytes) < float(maximum_bytes):
+        if float(used_bytes) < float(maximum_bytes):
             # We are within the allow quota exit.
             return
 
         # We should begin to delete old reports
-        amount_to_delete = float(maximum_bytes) - float(available_bytes)
+        amount_to_delete = float(used_bytes) - float(maximum_bytes)
         amount_deleted = 0
         measurement_path = FilePath(config.measurements_directory)
 



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits