]> source.dussan.org Git - nextcloud-server.git/commitdiff
fixed saving bug
authorTom Needham <needham.thomas@gmail.com>
Mon, 9 Jan 2012 17:03:19 +0000 (17:03 +0000)
committerTom Needham <needham.thomas@gmail.com>
Mon, 9 Jan 2012 17:03:19 +0000 (17:03 +0000)
apps/files_texteditor/ajax/savefile.php
apps/files_texteditor/js/editor.js

index 1e073f3ba24e3d47a8ef6ef4d5b953a3ed2e91c6..3d0771ea983f660e3b53ff21aa692b7436bd9485 100644 (file)
@@ -40,7 +40,8 @@ if($path != '' && $mtime != '')
        if($mtime != $filemtime)
        {
                // Then the file has changed since opening
-               OC_JSON::error();       
+               OC_JSON::error();
+               OC_Log::write('files_texteditor',"File: ".$path." modified since opening.",OC_Log::ERROR);      
        }
        else
        {
@@ -49,14 +50,20 @@ if($path != '' && $mtime != '')
                if(OC_Filesystem::is_writeable($path))  
                {
                        OC_Filesystem::file_put_contents($path, $filecontents);
-                       OC_JSON::success();
+                       // Clear statcache
+                       clearstatcache();
+                       // Get new mtime
+                       $newmtime = OC_Filesystem::filemtime($path);
+                       OC_JSON::success(array('data' => array('mtime' => $newmtime)));
                }
                else
                {
                        // Not writeable!
                        OC_JSON::error(array('data' => array( 'message' => 'Insufficient permissions')));       
+                       OC_Log::write('files_texteditor',"User does not have permission to write to file: ".$path,OC_Log::ERROR);
                }
        }
 } else {
-       OC_JSON::error(array('data' => array( 'message' => 'File path or mtime not supplied')));        
+       OC_JSON::error(array('data' => array( 'message' => 'File path or mtime not supplied')));
+       OC_Log::write('files_texteditor',"Invalid path supplied:".$path,OC_Log::ERROR); 
 }
index 060c76705a1e6db06b97ed3367dd8bb116ca88ea..3c1e1542806b144e8bf2b303e799a3173a71f4cb 100644 (file)
@@ -102,6 +102,9 @@ function doFileSave(){
                                }, 2000);       
                        } else {
                                // Save OK      
+                               // Update mtime
+                               $('#editor').attr('data-mtime',jsondata.data.mtime);
+                               // Show result
                                $('#saving_icon').remove();
                                $('#editor_save').after('<p id="save_result" style="float: left">Saved</p>')
                                setTimeout(function() {