Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
CIRCLE
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
94
Merge Requests
10
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
d7b19098
authored
Jan 29, 2013
by
tarokkk
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added folder tar.gz/download option
parent
00581971
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
7 deletions
+21
-7
miscellaneous/devenv/init.sh
+2
-0
miscellaneous/store-server/CloudStore.py
+19
-5
store/templates/store/list.html
+0
-2
No files found.
miscellaneous/devenv/init.sh
View file @
d7b19098
...
...
@@ -71,5 +71,7 @@ site_port = 9000
site_url = http://
${
LOCAL_IP
}
:%(site_port)s
#User manager script (add, del, set, update)
user_manager = FAKEUserManager.sh
#Temporary directory
temp_dir = /tmp/dl
EOF
sudo
/opt/webadmin/cloud/miscellaneous/store-server/CloudStore.py
>
/dev/null 2>&1 &
miscellaneous/store-server/CloudStore.py
View file @
d7b19098
...
...
@@ -25,6 +25,9 @@ USER_MANAGER = config.get('store', 'user_manager')
#Standalone server
SITE_HOST
=
config
.
get
(
'store'
,
'site_host'
)
SITE_PORT
=
config
.
get
(
'store'
,
'site_port'
)
#Temporary dir for tar.gz
TEMP_DIR
=
config
.
get
(
'store'
,
'temp_dir'
)
@route
(
'/'
)
def
index
():
...
...
@@ -59,21 +62,32 @@ def neptun_POST(neptun):
if
os
.
path
.
exists
(
list_path
)
!=
True
:
abort
(
404
,
"Path not found!"
)
else
:
return
list_directory
(
home_path
,
list_path
)
return
list_directory
(
home_path
,
list_path
)
#DOWNLOAD LINK GENERATOR
elif
request
.
json
[
'CMD'
]
==
'DOWNLOAD'
:
dl_path
=
home_path
+
'/'
+
request
.
json
[
'PATH'
]
dl_path
=
os
.
path
.
realpath
(
dl_path
)
if
not
dl_path
.
startswith
(
home_path
):
abort
(
400
,
'Invalid download path.'
)
if
(
os
.
path
.
isfile
(
dl_path
)
):
dl_hash
=
str
(
uuid
.
uuid4
())
if
(
os
.
path
.
isfile
(
dl_path
)
):
os
.
symlink
(
dl_path
,
ROOT_WWW_FOLDER
+
'/'
+
dl_hash
)
#Debug
#redirect('http://store.cloud.ik.bme.hu:8080/dl/'+dl_hash)
return
json
.
dumps
({
'LINK'
:
SITE_URL
+
'/dl/'
+
dl_hash
})
else
:
abort
(
400
,
'Can
\'
t download folder'
)
#Tar directore in /home/user
chdir
=
os
.
path
.
dirname
(
dl_path
)
folder_name
=
os
.
path
.
basename
(
dl_path
)
try
:
os
.
makedirs
(
TEMP_DIR
+
'/'
+
neptun
,
0700
)
except
:
pass
temp_path
=
TEMP_DIR
+
'/'
+
neptun
+
'/'
+
folder_name
+
'.tar.gz'
with
open
(
os
.
devnull
,
"w"
)
as
fnull
:
result
=
subprocess
.
call
([
'/bin/tar'
,
'zcvf'
,
temp_path
,
'-C'
,
chdir
,
folder_name
],
stdout
=
fnull
,
stderr
=
fnull
)
os
.
symlink
(
temp_path
,
ROOT_WWW_FOLDER
+
'/'
+
dl_hash
)
return
json
.
dumps
({
'LINK'
:
SITE_URL
+
'/dl/'
+
dl_hash
})
#UPLOAD
elif
request
.
json
[
'CMD'
]
==
'UPLOAD'
:
up_path
=
home_path
+
'/'
+
request
.
json
[
'PATH'
]
...
...
@@ -97,7 +111,7 @@ def neptun_POST(neptun):
if
not
dst_path
.
startswith
(
home_path
):
abort
(
400
,
'Invalid destination path.'
)
if
os
.
path
.
exists
(
src_path
)
==
True
and
os
.
path
.
exists
(
dst_path
)
==
True
and
os
.
path
.
isdir
(
dst_path
)
==
True
:
shutil
.
move
(
src_path
,
dst_path
)
shutil
.
move
(
src_path
,
dst_path
)
return
else
:
#TODO
...
...
@@ -190,7 +204,7 @@ def new_user(neptun):
@route
(
'/dl/<hash_num>'
,
method
=
'GET'
)
def
dl_hash
(
hash_num
):
hash_path
=
ROOT_WWW_FOLDER
if
os
.
path
.
exists
(
hash_path
)
!=
True
:
if
os
.
path
.
exists
(
hash_path
+
'/'
+
hash_num
)
!=
True
:
abort
(
404
,
"File not found!"
)
else
:
filename
=
os
.
path
.
basename
(
os
.
path
.
realpath
(
hash_path
+
'/'
+
hash_num
))
...
...
store/templates/store/list.html
View file @
d7b19098
...
...
@@ -71,13 +71,11 @@
<td>
{{ item.SIZE }}
</td>
<td>
{{ item.MTIME }}
</td>
<td>
{% if item.TYPE != 'D' %}
<form
action=
"/store/"
method=
"POST"
>
{% csrf_token %}
<input
type=
"submit"
value=
"Download"
>
<input
type=
"hidden"
name=
"path"
value=
"{{ path }}"
>
<input
type=
"hidden"
name=
"dl"
value=
"{{ path }}{{ item.NAME }}"
>
</form>
{% endif %}
</td>
<td>
<form
action=
"/store/"
method=
"POST"
>
{% csrf_token %}
...
...
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