Author: ab Date: Thu Dec 14 01:06:56 2006 New Revision: 487145 URL: http://svn.apache.org/viewvc?view=rev&rev=487145 Log: Check if paths exist before deleting them. Reported by Renaud Richardet.
Modified: lucene/nutch/branches/branch-0.8/src/java/org/apache/nutch/crawl/CrawlDb.java lucene/nutch/branches/branch-0.8/src/java/org/apache/nutch/crawl/LinkDb.java Modified: lucene/nutch/branches/branch-0.8/src/java/org/apache/nutch/crawl/CrawlDb.java URL: http://svn.apache.org/viewvc/lucene/nutch/branches/branch-0.8/src/java/org/apache/nutch/crawl/CrawlDb.java?view=diff&rev=487145&r1=487144&r2=487145 ============================================================================== --- lucene/nutch/branches/branch-0.8/src/java/org/apache/nutch/crawl/CrawlDb.java (original) +++ lucene/nutch/branches/branch-0.8/src/java/org/apache/nutch/crawl/CrawlDb.java Thu Dec 14 01:06:56 2006 @@ -98,11 +98,13 @@ FileSystem fs = new JobClient(job).getFs(); Path old = new Path(crawlDb, "old"); Path current = new Path(crawlDb, CrawlDatum.DB_DIR_NAME); - fs.delete(old); - fs.rename(current, old); + if (fs.exists(current)) { + if (fs.exists(old)) fs.delete(old); + fs.rename(current, old); + } fs.mkdirs(crawlDb); fs.rename(newCrawlDb, current); - fs.delete(old); + if (fs.exists(old)) fs.delete(old); } public static void main(String[] args) throws Exception { Modified: lucene/nutch/branches/branch-0.8/src/java/org/apache/nutch/crawl/LinkDb.java URL: http://svn.apache.org/viewvc/lucene/nutch/branches/branch-0.8/src/java/org/apache/nutch/crawl/LinkDb.java?view=diff&rev=487145&r1=487144&r2=487145 ============================================================================== --- lucene/nutch/branches/branch-0.8/src/java/org/apache/nutch/crawl/LinkDb.java (original) +++ lucene/nutch/branches/branch-0.8/src/java/org/apache/nutch/crawl/LinkDb.java Thu Dec 14 01:06:56 2006 @@ -279,11 +279,13 @@ FileSystem fs = new JobClient(job).getFs(); Path old = new Path(linkDb, "old"); Path current = new Path(linkDb, CURRENT_NAME); - fs.delete(old); - fs.rename(current, old); + if (fs.exists(current)) { + if (fs.exists(old)) fs.delete(old); + fs.rename(current, old); + } fs.mkdirs(linkDb); fs.rename(newLinkDb, current); - fs.delete(old); + if (fs.exists(old)) fs.delete(old); } public static void main(String[] args) throws Exception {