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
5701e08d
Commit
5701e08d
authored
Oct 28, 2020
by
Ozzieisaacs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix for #1668
parent
72a2fc49
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
16 deletions
+21
-16
helper.py
cps/helper.py
+21
-16
No files found.
cps/helper.py
View file @
5701e08d
...
@@ -373,21 +373,24 @@ def update_dir_structure_file(book_id, calibrepath, first_author, orignal_filepa
...
@@ -373,21 +373,24 @@ def update_dir_structure_file(book_id, calibrepath, first_author, orignal_filepa
new_name
=
get_valid_filename
(
localbook
.
title
)
+
' - '
+
get_valid_filename
(
new_authordir
)
new_name
=
get_valid_filename
(
localbook
.
title
)
+
' - '
+
get_valid_filename
(
new_authordir
)
try
:
try
:
if
orignal_filepath
:
if
orignal_filepath
:
os
.
renames
(
os
.
path
.
normcase
(
path
),
if
not
os
.
path
.
isdir
(
new_path
):
os
.
path
.
normcase
(
os
.
path
.
join
(
new_path
,
db_filename
)))
os
.
makedirs
(
new_path
)
shutil
.
move
(
os
.
path
.
normcase
(
path
),
os
.
path
.
normcase
(
os
.
path
.
join
(
new_path
,
db_filename
)))
log
.
debug
(
"Moving title:
%
s to
%
s/
%
s"
,
path
,
new_path
,
new_name
)
log
.
debug
(
"Moving title:
%
s to
%
s/
%
s"
,
path
,
new_path
,
new_name
)
# Check new path is not valid path
# Check new path is not valid path
elif
not
os
.
path
.
exists
(
new_path
):
else
:
# move original path to new path
if
not
os
.
path
.
exists
(
new_path
):
os
.
renames
(
os
.
path
.
normcase
(
path
),
os
.
path
.
normcase
(
new_path
))
# move original path to new path
log
.
debug
(
"Moving title:
%
s to
%
s"
,
path
,
new_path
)
log
.
debug
(
"Moving title:
%
s to
%
s"
,
path
,
new_path
)
else
:
# path is valid copy only files to new location (merge)
shutil
.
move
(
os
.
path
.
normcase
(
path
),
os
.
path
.
normcase
(
new_path
))
log
.
info
(
"Moving title:
%
s into existing:
%
s"
,
path
,
new_path
)
else
:
# path is valid copy only files to new location (merge)
# Take all files and subfolder from old path (strange command)
log
.
info
(
"Moving title:
%
s into existing:
%
s"
,
path
,
new_path
)
for
dir_name
,
__
,
file_list
in
os
.
walk
(
path
):
# Take all files and subfolder from old path (strange command)
for
file
in
file_list
:
for
dir_name
,
__
,
file_list
in
os
.
walk
(
path
):
os
.
renames
(
os
.
path
.
normcase
(
os
.
path
.
join
(
dir_name
,
file
)),
for
file
in
file_list
:
os
.
path
.
normcase
(
os
.
path
.
join
(
new_path
+
dir_name
[
len
(
path
):],
file
)))
shutil
.
move
(
os
.
path
.
normcase
(
os
.
path
.
join
(
dir_name
,
file
)),
os
.
path
.
normcase
(
os
.
path
.
join
(
new_path
+
dir_name
[
len
(
path
):],
file
)))
# os.unlink(os.path.normcase(os.path.join(dir_name, file)))
# change location in database to new author/title path
# change location in database to new author/title path
localbook
.
path
=
os
.
path
.
join
(
new_authordir
,
new_titledir
)
.
replace
(
'
\\
'
,
'/'
)
localbook
.
path
=
os
.
path
.
join
(
new_authordir
,
new_titledir
)
.
replace
(
'
\\
'
,
'/'
)
except
OSError
as
ex
:
except
OSError
as
ex
:
...
@@ -399,10 +402,12 @@ def update_dir_structure_file(book_id, calibrepath, first_author, orignal_filepa
...
@@ -399,10 +402,12 @@ def update_dir_structure_file(book_id, calibrepath, first_author, orignal_filepa
# Rename all files from old names to new names
# Rename all files from old names to new names
try
:
try
:
for
file_format
in
localbook
.
data
:
for
file_format
in
localbook
.
data
:
os
.
renames
(
os
.
path
.
normcase
(
shutil
.
move
(
os
.
path
.
normcase
(
os
.
path
.
join
(
new_path
,
file_format
.
name
+
'.'
+
file_format
.
format
.
lower
())),
os
.
path
.
join
(
new_path
,
file_format
.
name
+
'.'
+
file_format
.
format
.
lower
())),
os
.
path
.
normcase
(
os
.
path
.
join
(
new_path
,
new_name
+
'.'
+
file_format
.
format
.
lower
())))
os
.
path
.
normcase
(
os
.
path
.
join
(
new_path
,
new_name
+
'.'
+
file_format
.
format
.
lower
())))
file_format
.
name
=
new_name
file_format
.
name
=
new_name
if
not
orignal_filepath
and
len
(
os
.
listdir
(
os
.
path
.
dirname
(
path
)))
==
0
:
shutil
.
rmtree
(
os
.
path
.
dirname
(
path
))
except
OSError
as
ex
:
except
OSError
as
ex
:
log
.
error
(
"Rename file in path
%
s to
%
s:
%
s"
,
new_path
,
new_name
,
ex
)
log
.
error
(
"Rename file in path
%
s to
%
s:
%
s"
,
new_path
,
new_name
,
ex
)
log
.
debug
(
ex
,
exc_info
=
True
)
log
.
debug
(
ex
,
exc_info
=
True
)
...
...
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