From 03a6ad2fde52ea304e2384e57689fb74a4974083 Mon Sep 17 00:00:00 2001 From: Jacob Matthews Date: Tue, 18 Jul 2006 15:47:27 +0000 Subject: [PATCH] Fixed bug in which removing a devel link could cause an error if the cache.ss file for the given version number didn't exist (e.g. because a devel link was installed, then mzscheme was upgraded, and then the devel link was removed) svn: r3751 --- collects/planet/util.ss | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/collects/planet/util.ss b/collects/planet/util.ss index 300f697540..0b143f9dcb 100644 --- a/collects/planet/util.ss +++ b/collects/planet/util.ss @@ -69,14 +69,15 @@ ;; remove-infodomain-entries : path -> void (define (remove-infodomain-entries path) (let* ([pathbytes (path->bytes path)] - [cache-file (build-path (PLANET-DIR) "cache.ss")] - [cache-lines (with-input-from-file cache-file read)]) - (with-output-to-file cache-file - (lambda () - (if (pair? cache-lines) - (write (filter (lambda (line) (not (and (pair? line) (equal? (car line) pathbytes)))) cache-lines)) - (printf "\n"))) - 'truncate/replace))) + [cache-file (build-path (PLANET-DIR) "cache.ss")]) + (when (file-exists? cache-file) + (let ([cache-lines (with-input-from-file cache-file read)]) + (with-output-to-file cache-file + (lambda () + (if (pair? cache-lines) + (write (filter (lambda (line) (not (and (pair? line) (equal? (car line) pathbytes)))) cache-lines)) + (printf "\n"))) + 'truncate/replace))))) ;; listof X * listof X -> nonempty listof X ;; returns de-prefixed version of l2 if l1 is a proper prefix of l2;