~artem-anufrij/scratch/dont-force-to-save-unsaved

« back to all changes in this revision

Viewing changes to src/Services/Document.vala

  • Committer: artem-anufrij
  • Date: 2014-10-04 16:42:14 UTC
  • Revision ID: artem-anufrij-20141004164214-b9gem6o9eto0tsjb
Delete old backup file after 'save as...'

Show diffs side-by-side

added added

removed removed

Lines of Context:
317
317
            // Reset the last saved content
318
318
            last_saved_content = null;            
319
319
 
320
 
            if (save () && is_current_file_temporary) {
321
 
                // Delete temporary file              
 
320
            if (save () && is_current_file_temporary) {                              
322
321
                try {
 
322
                    // Delete temporary file
323
323
                    File.new_for_path (current_file).delete ();
324
324
                } catch (Error err) {
325
325
                    message ("Temporary file cannot be deleted: %s", current_file);
326
326
                }
327
327
            }
 
328
 
 
329
            // Delete backup file
 
330
            delete_backup (current_file + "~");
 
331
 
328
332
            // Change syntax highlight
329
333
            this.source_view.change_syntax_highlight_from_file (this.file);
330
334
 
640
644
            }
641
645
        }
642
646
 
643
 
        private void delete_backup () {
644
 
            string backup_file = file.get_path () + "~";
 
647
        private void delete_backup (string? backup_path = null) {
 
648
 
 
649
            string backup_file  = "";
 
650
 
 
651
            if (backup_path == null)
 
652
                backup_file = file.get_path () + "~";
 
653
            else
 
654
                backup_file = backup_path;
 
655
 
645
656
            debug ("Backup file deleting: %s", backup_file);
646
657
            
647
658
            var backup = File.new_for_path (backup_file);