Skip to content

Commit 2c9a085

Browse files
committed
Fix Mac .DS_Store file bug
1 parent 7166bdc commit 2c9a085

File tree

7 files changed

+21
-20
lines changed

7 files changed

+21
-20
lines changed

Diff for: LocalNote/controllers.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,8 @@ def download_notes(self, update = True):
8989
noteDict = self.es.get_note_dict()
9090
invalidNoteList = []
9191
def _download_note(noteFullPath):
92-
if any(c in ''.join(noteFullPath).decode('utf8') for c in u'\\/:*?"<>|\xa0'):
92+
if (any(c in ''.join(noteFullPath).decode('utf8') for c in u'\\/:*?"<>|\xa0')
93+
or noteFullPath[1] == '.DS_Store'):
9394
invalidNoteList.append(noteFullPath)
9495
return
9596
print(('Downloading '+'/'.join(noteFullPath)).decode('utf8'))
@@ -113,7 +114,8 @@ def _download_note(noteFullPath):
113114
for noteFullPath, status in self.__get_changes(update):
114115
if status not in (-1, 0):
115116
continue
116-
elif any(c in ''.join(noteFullPath).decode('utf8') for c in u'\\/:*?"<>|\xa0'):
117+
elif (any(c in ''.join(noteFullPath).decode('utf8') for c in u'\\/:*?"<>|\xa0')
118+
or noteFullPath[0] == '.DS_Store'):
117119
invalidNoteList.append(noteFullPath)
118120
continue
119121
elif 1 < len(noteFullPath):

Diff for: LocalNote/local/storage.py

+11-2
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,10 @@ def get_file_dict(self, notebooksList = None):
114114
for nbName in os.walk('.').next()[1]: # get folders
115115
nbNameUtf8 = self.__str_l2c(nbName)
116116
if notebooksList is not None and nbNameUtf8 not in notebooksList: continue
117+
if nbNameUtf8 == '.DS_Store': continue # Mac .DS_Store ignorance
117118
fileDict[nbNameUtf8] = []
118119
for nName in reduce(lambda x,y: x+y, os.walk(nbName).next()[1:]): # get folders and files
120+
if nName == '.DS_Store': continue # Mac .DS_Store ignorance
119121
filePath = join(nbName, nName)
120122
if os.path.isdir(filePath):
121123
fileDict[nbNameUtf8].append((self.__str_l2c(nName), os.stat(filePath).st_mtime))
@@ -135,20 +137,27 @@ def check_files_format(self):
135137
r = [] # (filename, status) 1 for wrong placement, 2 for too large, 3 for missing main file
136138
notebooks, notes = os.walk('.').next()[1:]
137139
for note in notes:
138-
if note != 'user.cfg': r.append((self.__str_l2c(note), 1))
140+
if note not in ('user.cfg', '.DS_Store'): r.append((self.__str_l2c(note), 1))
139141
for notebook in notebooks:
142+
if notebook == '.DS_Store': # Mac .DS_Store ignorance
143+
r.append(('.DS_Store', 1))
144+
continue
140145
folderNotes, notes = os.walk(notebook).next()[1:]
141146
for note in notes:
147+
if note == '.DS_Store': continue# Mac .DS_Store ignorance
142148
if re.compile('.+\.(md|html)').match(note):
143149
if self.maxUpload < os.path.getsize(join(notebook, note)):
144150
r.append((self.__str_l2c(join(notebook, note)), 2))
145151
else:
146152
r.append((self.__str_l2c(join(notebook, note)), 3))
147153
for folderNote in folderNotes:
154+
if folderNote == '.DS_Store':
155+
r.append((self.__str_l2c(join(notebook, folderNote)), 1))
156+
continue# Mac .DS_Store ignorance
148157
size = 0
149158
wrongFolders, attas = os.walk(join(notebook, folderNote)).next()[1:]
150159
if filter(lambda x: re.compile('.+\.(md|html)').match(x), attas) == []:
151-
r.append((self.__str_l2c(join(notebook, folderNote), 3)))
160+
r.append((self.__str_l2c(join(notebook, folderNote)), 3))
152161
for atta in attas: size += os.path.getsize(join(notebook, folderNote, atta))
153162
for wrongFolder in wrongFolders:
154163
r.append((self.__str_l2c(join(notebook, folderNote, wrongFolder)), 1))

Diff for: LocalNote/main.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from local import clear_dir
77
from exception import main_wrapper
88

9-
DEBUG = True
9+
DEBUG = False
1010

1111
def sys_print(s, level = 'info'):
1212
print(('[%-4s] %s'%((level+' '*4)[:4].upper(), s.replace(u'\xa0', ' '))).encode(sys.stdin.encoding))
@@ -27,7 +27,8 @@ def _check_files_format(*args, **kwargs):
2727
sys_print(u'检测到内容过大的文件:'+fileName.decode('utf8'), 'warn')
2828
elif status == 3:
2929
sys_print(u'检测到意义不明的文件:'+fileName.decode('utf8'), 'warn')
30-
sys_print(u'请确保单条笔记有md或html的正文且不大于%s字节,笔记中没有文件夹格式的附件。'%mainController.ls.maxUpload, 'info')
30+
sys_print(u'请确保单条笔记有md或html的正文且不大于%s字节'%mainController.ls.maxUpload)
31+
sys_print(u'请确保没有文件夹格式的附件,或名为.DS_Store的笔记及笔记本。')
3132
else:
3233
return fn(mainController, *args, **kwargs)
3334
else:
@@ -106,7 +107,8 @@ def pull(mainController, *args):
106107
if sys_input(u'是否更新本地文件?[yn] ') == 'y':
107108
r = mainController.download_notes(False)
108109
if isinstance(r, list):
109-
sys_print(u'为存储到本地,请确保笔记名字中没有特殊字符“\\/:*?"<>|”或特殊的不可见字符')
110+
sys_print(u'为存储到本地,请确保笔记名字中没有特殊字符“\\/:*?"<>|”或特殊不可见字符')
111+
sys_print(u'为兼容Mac电脑,需要将名字为".DS_Store"的笔记本或笔记更名')
110112
for noteFullPath in r: sys_print('/'.join(noteFullPath).decode('utf8'))
111113
print('Bye~')
112114
@check_files_format

Diff for: README.md

-4
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,6 @@ Root
7171

7272
# FAQ
7373

74-
Q: 在使用时抛出了`errorCode=19`的异常,没有办法使用,怎么办?
75-
76-
A: 这是你的账号每小时操作次数限制到了,等待一个小时再使用即可。完整异常为:`evernote.edam.error.ttypes.EDAMSystemException: EDAMSystemException(errorCode=19, rateLimitDuration=1039, _message=None)`。在被限制期间登录也会受限,所以会提示尚未登录。
77-
7874
Q: 第一次使用需要下载很久么?
7975

8076
A: 取决于你笔记中内容的多少,一般下载速度为200k/s。

Diff for: README.rst

-4
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,6 @@ Example file tree
7575

7676
**FAQ**
7777

78-
Q: I have an error `errorCode=19`, how should I deal with it?
79-
80-
A: This is the hourly limit of evernote, you just need to wait for an hour. The whole Exception is `evernote.edam.error.ttypes.EDAMSystemException: EDAMSystemException(errorCode=19, rateLimitDuration=1039, _message=None)`. Login will also be limited in the hour, so warning about not loged in will be shown.
81-
8278
Q: Will the first pull take a long time?
8379

8480
A: It depands how big your files are, the downloading speed is about 200k/s.

Diff for: README_EN.md

-4
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,6 @@ Root
7070

7171
# FAQ
7272

73-
Q: I have an error `errorCode=19`, how should I deal with it?
74-
75-
A: This is the hourly limit of evernote, you just need to wait for an hour. The whole Exception is `evernote.edam.error.ttypes.EDAMSystemException: EDAMSystemException(errorCode=19, rateLimitDuration=1039, _message=None)`. Login will also be limited in the hour, so warning about not loged in will be shown.
76-
7773
Q: Will the first pull take a long time?
7874

7975
A: It depands how big your files are, the downloading speed is about 200k/s.

Diff for: setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
setup(
1717
name='LocalNote',
1818

19-
version='1.0.11',
19+
version='1.0.14',
2020

2121
description='LocalNote让你能够像使用本地文件一样使用印象笔记,支持markdown语法。Use your evernote like local file system in all platforms (markdown supported)',
2222

0 commit comments

Comments
 (0)