Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
D
douban-api-proxy
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
captainwong
douban-api-proxy
Commits
20c6f79a
Commit
20c6f79a
authored
Jul 05, 2020
by
Ozzieisaacs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Changed behavior delete books with subfolders (additional warning message, but book is deleted)
parent
ee6f1405
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
6 deletions
+7
-6
helper.py
cps/helper.py
+7
-6
No files found.
cps/helper.py
View file @
20c6f79a
...
@@ -295,15 +295,16 @@ def delete_book_file(book, calibrepath, book_format=None):
...
@@ -295,15 +295,16 @@ def delete_book_file(book, calibrepath, book_format=None):
return
True
,
None
return
True
,
None
else
:
else
:
if
os
.
path
.
isdir
(
path
):
if
os
.
path
.
isdir
(
path
):
if
len
(
next
(
os
.
walk
(
path
))[
1
]):
log
.
error
(
"Deleting book
%
s failed, path has subfolders:
%
s"
,
book
.
id
,
book
.
path
)
return
False
,
_
(
"Deleting book
%(id)
s failed, path has subfolders:
%(path)
s"
,
id
=
book
.
id
,
path
=
book
.
path
)
try
:
try
:
for
root
,
__
,
files
in
os
.
walk
(
path
):
for
root
,
folders
,
files
in
os
.
walk
(
path
):
for
f
in
files
:
for
f
in
files
:
os
.
unlink
(
os
.
path
.
join
(
root
,
f
))
os
.
unlink
(
os
.
path
.
join
(
root
,
f
))
if
len
(
folders
):
log
.
warning
(
"Deleting book {} failed, path {} has subfolders: {}"
.
format
(
book
.
id
,
book
.
path
,
folders
))
return
True
,
_
(
"Deleting bookfolder for book
%(id)
s failed, path has subfolders:
%(path)
s"
,
id
=
book
.
id
,
path
=
book
.
path
)
shutil
.
rmtree
(
path
)
shutil
.
rmtree
(
path
)
except
(
IOError
,
OSError
)
as
e
:
except
(
IOError
,
OSError
)
as
e
:
log
.
error
(
"Deleting book
%
s failed:
%
s"
,
book
.
id
,
e
)
log
.
error
(
"Deleting book
%
s failed:
%
s"
,
book
.
id
,
e
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment