diff options
| author | hallgren <hallgren@chalmers.se> | 2011-07-07 13:30:56 +0000 |
|---|---|---|
| committer | hallgren <hallgren@chalmers.se> | 2011-07-07 13:30:56 +0000 |
| commit | c7fffd861b4fa74afc450be2970cd8cf63f64a88 (patch) | |
| tree | 4a38edebc5b6027bd8f4737e833c117af7cb85c2 /src | |
| parent | f224ead86b266c3c6c01a68c592ea589b0eba1bd (diff) | |
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.
Diffstat (limited to 'src')
| -rw-r--r-- | src/editor/simple/editor.js | 7 | ||||
| -rw-r--r-- | src/editor/simple/upload.cgi | 26 |
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 |
