Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
3pia
VISPA
VISPA web
Commits
976b3ab0
Commit
976b3ab0
authored
Oct 14, 2015
by
Fabian-Andree Heidemann
Browse files
[filebrowser] fix #2171, handle exceptions of filesystem on controller and client side
parent
c9aa7798
Changes
4
Hide whitespace changes
Inline
Side-by-side
vispa/controller/filesystem.py
View file @
976b3ab0
...
...
@@ -169,7 +169,10 @@ class FSAjaxController(AbstractController):
self
.
release_session
()
fs
=
self
.
get
(
'fs'
)
self
.
release_database
()
return
fs
.
rename
(
path
,
name
,
new_name
)
try
:
fs
.
rename
(
path
,
name
,
new_name
)
except
Exception
as
e
:
raise
AjaxException
(
str
(
e
).
split
(
"
\n
"
)[
0
])
@
cherrypy
.
expose
@
cherrypy
.
tools
.
method
(
accept
=
"POST"
)
...
...
@@ -197,7 +200,10 @@ class FSAjaxController(AbstractController):
destination
=
json
.
loads
(
destination
)
# 'source' and 'destination' can be a unicode/string or list of unicodes/strings
# so convert it with the convert function
fs
.
move
(
source
,
destination
)
try
:
fs
.
move
(
source
,
destination
)
except
Exception
as
e
:
raise
AjaxException
(
str
(
e
).
split
(
"
\n
"
)[
0
])
@
cherrypy
.
expose
@
cherrypy
.
tools
.
method
(
accept
=
"POST"
)
...
...
@@ -208,7 +214,10 @@ class FSAjaxController(AbstractController):
# 'paths' can be a unicode/string or list of unicodes/strings
# so convert it with the convert function
paths
=
json
.
loads
(
paths
)
fs
.
compress
(
path
,
paths
,
name
)
try
:
fs
.
compress
(
path
,
paths
,
name
)
except
Exception
as
e
:
raise
AjaxException
(
str
(
e
).
split
(
"
\n
"
)[
0
])
@
cherrypy
.
expose
@
cherrypy
.
tools
.
method
(
accept
=
"POST"
)
...
...
@@ -216,7 +225,11 @@ class FSAjaxController(AbstractController):
self
.
release_session
()
fs
=
self
.
get
(
'fs'
)
self
.
release_database
()
fs
.
decompress
(
file
)
try
:
fs
.
decompress
(
file
)
except
Exception
as
e
:
raise
AjaxException
(
str
(
e
).
split
(
"
\n
"
)[
0
])
@
cherrypy
.
expose
@
cherrypy
.
tools
.
method
(
accept
=
"POST"
)
...
...
@@ -229,8 +242,10 @@ class FSAjaxController(AbstractController):
# path = fs.expand(path.encode("utf-8"))
# 'paths' can be a unicode/string or list of unicodes/strings
# so convert it with the convert function
fs
.
paste
(
path
,
paths
,
self
.
convert
(
cut
,
bool
))
return
try
:
fs
.
paste
(
path
,
paths
,
self
.
convert
(
cut
,
bool
))
except
Exception
as
e
:
raise
AjaxException
(
str
(
e
).
split
(
"
\n
"
)[
0
])
@
cherrypy
.
expose
@
cherrypy
.
tools
.
method
(
accept
=
"POST"
)
...
...
@@ -263,35 +278,39 @@ class FSAjaxController(AbstractController):
lastbyte
=
int
(
tmp
[
1
])
path
=
kwargs
[
'path'
]
for
part
in
parts
:
filename
=
fs
.
handle_file_name_collision
(
part
.
filename
,
path
)
if
chunked
:
filename
=
'~'
+
filename
if
chunked
and
(
firstbyte
!=
0
):
# check correct size of previous chunks
for
file
in
fs
.
get_file_list
(
path
,
encode_json
=
False
)[
'filelist'
]:
if
file
[
'name'
]
==
filename
and
file
[
'size'
]
!=
firstbyte
:
raise
AjaxException
(
"Chunked upload failed"
)
append
=
True
else
:
append
=
False
while
True
:
data
=
part
.
file
.
read
(
1024
**
2
)
if
len
(
data
)
<=
0
:
break
try
:
for
part
in
parts
:
filename
=
fs
.
handle_file_name_collision
(
part
.
filename
,
path
)
if
chunked
:
filename
=
'~'
+
filename
if
chunked
and
(
firstbyte
!=
0
):
# check correct size of previous chunks
for
file
in
fs
.
get_file_list
(
path
,
encode_json
=
False
)[
'filelist'
]:
if
file
[
'name'
]
==
filename
and
file
[
'size'
]
!=
firstbyte
:
raise
AjaxException
(
"Chunked upload failed"
)
append
=
True
else
:
append
=
False
while
True
:
data
=
part
.
file
.
read
(
1024
**
2
)
if
len
(
data
)
<=
0
:
break
success
,
msg
=
fs
.
save_file_content
(
filename
,
data
,
path
=
path
,
force
=
True
,
append
=
append
)
if
not
success
:
raise
AjaxException
(
msg
)
success
,
msg
=
fs
.
save_file_content
(
filename
,
data
,
path
=
path
,
force
=
True
,
append
=
append
)
if
not
success
:
raise
AjaxException
(
msg
)
if
not
append
:
append
=
True
if
not
append
:
append
=
True
if
chunked
and
(
lastbyte
+
1
==
maxbytes
):
fs
.
rename
(
path
,
filename
,
filename
.
lstrip
(
'~'
))
if
chunked
and
(
lastbyte
+
1
==
maxbytes
):
fs
.
rename
(
path
,
filename
,
filename
.
lstrip
(
'~'
))
except
Exception
as
e
:
raise
AjaxException
(
str
(
e
).
split
(
"
\n
"
)[
0
])
@
cherrypy
.
expose
@
cherrypy
.
tools
.
method
(
accept
=
"GET"
)
...
...
@@ -306,7 +325,7 @@ class FSAjaxController(AbstractController):
else
:
return
"File can not be opened in browser."
except
Exception
as
e
:
r
eturn
str
(
e
)
r
aise
AjaxException
(
str
(
e
).
split
(
"
\n
"
)[
0
]
)
@
cherrypy
.
expose
@
cherrypy
.
tools
.
method
(
accept
=
"GET"
)
...
...
vispa/extensions/file/static/js/base/actions.js
View file @
976b3ab0
...
...
@@ -488,6 +488,7 @@ define(["jquery", "jclass"], function($, JClass) {
if
(
data
.
errorThrown
===
"
abort
"
)
{
vispa
.
messenger
.
info
(
"
Upload aborted
"
,
"
glyphicon glyphicon-stop
"
);
}
else
{
self
.
FileBase
.
instance
.
alert
(
data
.
jqXHR
.
responseJSON
.
message
);
vispa
.
messenger
.
info
(
"
Upload failed
"
,
"
glyphicon glyphicon-warning-sign
"
);
}
},
...
...
vispa/extensions/file/static/js/base/views/table.js
View file @
976b3ab0
...
...
@@ -224,12 +224,11 @@ define(["jquery", "jclass"], function($, JClass) {
var
name
=
node
.
data
(
"
data
"
).
name
;
var
newName
=
replaceWith
.
val
();
// only rename when new filename not equal to original filename
if
(
newName
===
name
||
newName
===
""
)
{
replaceWith
.
hide
();
origin
.
show
();
}
else
{
if
(
newName
!==
name
&&
newName
!==
""
)
{
self
.
FileBase
.
actions
.
_rename
(
path
,
name
,
newName
);
}
replaceWith
.
hide
();
origin
.
show
();
// enable drag and drop
node
.
attr
(
"
draggable
"
,
"
true
"
);
// show edit tools on hover
...
...
vispa/remote/filesystem.py
View file @
976b3ab0
...
...
@@ -277,15 +277,11 @@ class FileSystem(object):
name
=
self
.
expand
(
name
)
new_name
=
self
.
expand
(
new_name
)
try
:
if
force
==
False
:
new_name
=
self
.
handle_file_name_collision
(
new_name
,
path
)
name
=
os
.
path
.
join
(
path
,
name
)
new_name
=
os
.
path
.
join
(
path
,
new_name
)
os
.
renames
(
name
,
new_name
)
return
except
Exception
as
e
:
return
str
(
e
)
if
force
==
False
:
new_name
=
self
.
handle_file_name_collision
(
new_name
,
path
)
name
=
os
.
path
.
join
(
path
,
name
)
new_name
=
os
.
path
.
join
(
path
,
new_name
)
os
.
renames
(
name
,
new_name
)
def
remove
(
self
,
path
):
if
isinstance
(
path
,
list
):
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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