cgi#out_channel#commit_work()
;;
+exception File_already_exists;;
+
let save (cgi : Netcgi1_compat.Netcgi_types.cgi_activation) =
let cgi = Netcgi1_compat.Netcgi_types.of_compat_activation cgi in
let env = cgi#environment in
let locked = cgi#argument_value "locked" in
let unlocked = cgi#argument_value "unlocked" in
let filename = libdir uid ^ "/" ^ (cgi # argument_value "file") in
+ let force = bool_of_string (cgi#argument_value "force") in
prerr_endline ("Matita will save the file for user " ^ uid);
+
+ if ((not force) && (Sys.file_exists filename)) then
+ raise File_already_exists;
+
let oc = open_out filename in
output_string oc (locked ^ unlocked);
close_out oc;
();
cgi#out_channel#output_string "<response>ok</response>"
with
- | Not_found _ ->
+ | File_already_exists ->
+ cgi#out_channel#output_string "<response>cancelled</response>"
+ | Sys_error _ ->
cgi # set_header
~status:`Internal_server_error
~cache:`No_cache