Fix unicode error for Espen.

master
Jason A. Donenfeld 2011-05-12 21:38:14 -04:00
parent ca7dfb7556
commit 567f38e88b
1 changed files with 9 additions and 0 deletions

View File

@ -1,5 +1,6 @@
import os import os
import os.path import os.path
import sys
from datetime import datetime from datetime import datetime
from PhotoAlbum import Photo, Album, PhotoAlbumEncoder from PhotoAlbum import Photo, Album, PhotoAlbumEncoder
from CachePath import json_cache, set_cache_path_base, file_mtime from CachePath import json_cache, set_cache_path_base, file_mtime
@ -34,6 +35,10 @@ class TreeWalker:
for entry in os.listdir(path): for entry in os.listdir(path):
if entry[0] == '.': if entry[0] == '.':
continue continue
try:
entry = entry.decode(sys.getfilesystemencoding())
except:
pass
entry = os.path.join(path, entry) entry = os.path.join(path, entry)
if os.path.isdir(entry): if os.path.isdir(entry):
album.add_album(self.walk(entry)) album.add_album(self.walk(entry))
@ -83,6 +88,10 @@ class TreeWalker:
all_cache_entries[entry] = True all_cache_entries[entry] = True
print "Searching stale cache entries." print "Searching stale cache entries."
for cache in os.listdir(self.cache_path): for cache in os.listdir(self.cache_path):
try:
cache = cache.decode(sys.getfilesystemencoding())
except:
pass
if cache not in all_cache_entries: if cache not in all_cache_entries:
print "Removing stale cache %s" % cache print "Removing stale cache %s" % cache
os.unlink(os.path.join(self.cache_path, cache)) os.unlink(os.path.join(self.cache_path, cache))