forked from GitHub/gf-core
gfse: grammars in the cloud, work in progress
Cloud merging: when sharing grammars between two devices that previously each had separate grammar directoies on the server, clean up one of the directories and make it a symbolic link to the other.
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user