summaryrefslogtreecommitdiff
path: root/src/editor/simple
diff options
context:
space:
mode:
Diffstat (limited to 'src/editor/simple')
-rw-r--r--src/editor/simple/editor.js7
-rw-r--r--src/editor/simple/upload.cgi26
2 files changed, 32 insertions, 1 deletions
diff --git a/src/editor/simple/editor.js b/src/editor/simple/editor.js
index ea56548a4..9954c5f7e 100644
--- a/src/editor/simple/editor.js
+++ b/src/editor/simple/editor.js
@@ -969,7 +969,12 @@ function download_from_cloud() {
var newdir="/tmp/"+location.hash.substr(1)
local.put("dir",newdir);
if(olddir && uploaded && newdir!=olddir) {
- upload_json(function(){download_json(newdir)})
+ function download() { download_json(newdir) }
+ function rmolddir(){
+ ajax_http_get("upload.cgi?rmdir="+olddir+"&newdir="+newdir,
+ download,download)
+ }
+ upload_json(rmolddir)
}
else download_json(newdir)
}
diff --git a/src/editor/simple/upload.cgi b/src/editor/simple/upload.cgi
index f7dd936f9..ec262a062 100644
--- a/src/editor/simple/upload.cgi
+++ b/src/editor/simple/upload.cgi
@@ -153,6 +153,32 @@ case "$REQUEST_METHOD" in
*) error400
esac
;;
+ rmdir=*)
+ dir=$(qparse "$QUERY_STRING" rmdir)
+ case "$dir" in
+ /tmp/gfse.*) # shouldn't allow .. in path !!!
+ path="$documentRoot$dir"
+ if [ -d "$path" ] ; then
+ ContentType="text/plain; charset=$charset"
+ cgiheaders
+ cd "$path"
+ rm *.gf *.gfo *-*.json *.pgf grammars.cgi
+ cd ..
+ rmdir "$path"
+ newdir=$(qparse "$QUERY_STRING" newdir)
+ case "$newdir" in
+ /tmp/gfse.*) # shouldn't allow .. in path !!!
+ newnode="${newdir##*/}"
+ oldnode="${path##*/}"
+ ln -s "$newnode" "$oldnode"
+ esac
+ else
+ error404
+ fi
+ ;;
+ *) error400
+ esac
+ ;;
download=*)
file=$(qparse "$QUERY_STRING" download)
case "$file" in