$OpenBSD: patch-src_PartFile_cpp,v 1.1 2012/11/26 12:11:35 dcoppa Exp $

From 151869b449d49155ea57a2f47579930dca71ea4a Mon Sep 17 00:00:00 2001
From: upstream svn <svn@amule.org>
Date: Sun, 4 Nov 2012 16:32:47 +0000
Subject: [PATCH] Delete broken seeds files

--- src/PartFile.cpp.orig	Mon Nov 26 11:12:14 2012
+++ src/PartFile.cpp	Mon Nov 26 11:17:13 2012
@@ -1046,21 +1046,17 @@ void CPartFile::LoadSourceSeeds()
 	
 	CFile file(seedsPath, CFile::read);
 	if (!file.IsOpened()) {
-		AddLogLineN(CFormat( _("Partfile %s (%s) has no seeds file") )
+		// Exists but can't be opened. Should not happen. Probably permission problem, try to remove it.
+		AddLogLineN(CFormat( _("Can't read seeds file for Partfile %s (%s)") )
 			% m_partmetfilename
 			% GetFileName() );
+		CPath::RemoveFile(seedsPath);
 		return;
 	}	
 	
 		
+	bool badSeedsFile = false;
 	try {
-		if (file.GetLength() <= 1) {
-			AddLogLineN(CFormat( _("Partfile %s (%s) has a void seeds file") )
-				% m_partmetfilename
-				% GetFileName() );
-			return;
-		}
-
 		uint8 src_count = file.ReadUInt8();
 
 		bool bUseSX2Format = (src_count == 0);
@@ -1115,9 +1111,14 @@ void CPartFile::LoadSourceSeeds()
 				% m_partmetfilename
 				% GetFileName()
 				% e.what() );		
+		badSeedsFile = true;
 	}
 
 	file.Close();
+	if (badSeedsFile) {
+		// If we got an exception reading it remove it.
+		CPath::RemoveFile(seedsPath);
+	}
 }		
 
 void CPartFile::PartFileHashFinished(CKnownFile* result)
