[Pkg-ocaml-maint-commits] [approx] 02/16: eliminate Not_found exception in gc (closes: #695639)
Eric Cooper
ecc at cmu.edu
Mon Dec 9 15:44:02 UTC 2013
This is an automated email from the git hooks/post-receive script.
ecc-guest pushed a commit to branch upstream
in repository approx.
commit 6f5dda6019e5112798582492e983d060c7af6d27
Author: Eric Cooper <ecc at cmu.edu>
Date: Fri Mar 8 13:37:21 2013 -0500
eliminate Not_found exception in gc (closes: #695639)
---
config.ml | 7 ++++---
gc.ml | 5 +++--
2 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/config.ml b/config.ml
index 1910843..1149130 100644
--- a/config.ml
+++ b/config.ml
@@ -1,5 +1,5 @@
(* approx: proxy server for Debian archive files
- Copyright (C) 2012 Eric C. Cooper <ecc at cmu.edu>
+ Copyright (C) 2013 Eric C. Cooper <ecc at cmu.edu>
Released under the GNU General Public License *)
open Config_file
@@ -35,12 +35,13 @@ let cache_dir = get "$cache" ~default: "/var/cache/approx"
let params = ("$cache", cache_dir) :: params
let split_cache_path path =
+ let err () = invalid_string_arg "split_cache_path" path in
if is_prefix cache_dir path then
let i = String.length cache_dir + 1 in
- let j = String.index_from path i '/' in
+ let j = try String.index_from path i '/' with Not_found -> err () in
substring path ~from: i ~until: j, substring path ~from: (j + 1)
else
- invalid_string_arg "split_cache_path" path
+ err ()
let shorten path =
if is_prefix cache_dir path then
diff --git a/gc.ml b/gc.ml
index 40ff974..82ef589 100644
--- a/gc.ml
+++ b/gc.ml
@@ -1,5 +1,5 @@
(* approx: proxy server for Debian archive files
- Copyright (C) 2012 Eric C. Cooper <ecc at cmu.edu>
+ Copyright (C) 2013 Eric C. Cooper <ecc at cmu.edu>
Released under the GNU General Public License *)
(* Garbage-collect the approx cache using a mark-sweep algorithm *)
@@ -60,7 +60,8 @@ let distributions =
(* Check if a file is part of a known distribution *)
let dist_is_known file =
- List.mem (fst (split_cache_path file)) distributions
+ try List.mem (fst (split_cache_path file)) distributions
+ with Invalid_argument _ -> false
(* Check if a Release file is no more than 5 minutes older
than an InRelease file in the same directory, or vice versa *)
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-ocaml-maint/packages/approx.git
More information about the Pkg-ocaml-maint-commits
mailing list