git » sea » commit a74898f

Create the directory only when we know we have something to put in there

author Alberto Bertogli
2010-05-09 00:41:51 UTC
committer Alberto Bertogli
2010-05-09 00:41:51 UTC
parent 2c77293cb75895eb0dd54a61d9b6e09ddc12563a

Create the directory only when we know we have something to put in there

Signed-off-by: Alberto Bertogli <albertito@blitiri.com.ar>

sea +5 -3

diff --git a/sea b/sea
index 248d356..12dbf48 100755
--- a/sea
+++ b/sea
@@ -33,9 +33,6 @@ def main(infd, basepath):
 	outpath = "%s/%s~%s/" % (basepath, f_email.replace('/', ''),
 			time.strftime("%Y-%m-%d-%H:%M:%S", date))
 
-	if not os.path.exists(outpath):
-		os.mkdir(outpath)
-
 	count = 0
 	for part in m.walk():
 		count += 1
@@ -47,6 +44,11 @@ def main(infd, basepath):
 			# text is not interesting
 			continue
 
+		# do this here, once we know there is something to put in the
+		# directory
+		if not os.path.exists(outpath):
+			os.mkdir(outpath)
+
 		fname = part.get_filename('')
 		if not fname:
 			ext = mimetypes.guess_extension(