~deja-dup-hackers/deja-dup/22

« back to all changes in this revision

Viewing changes to common/Duplicity.vala

  • Committer: Michael Terry
  • Date: 2012-01-09 13:36:21 UTC
  • mfrom: (1265.1.3 read-error)
  • Revision ID: michael.terry@canonical.com-20120109133621-9fc30d8ld8cqxths
warn user if we fail to back up a file

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
   * vala withot the need of manually running duplicity command.
31
31
   */
32
32
 
33
 
  public signal void done(bool success, bool cancelled);
 
33
  public signal void done(bool success, bool cancelled, string? detail);
34
34
  public signal void raise_error(string errstr, string? detail);
35
35
  public signal void action_desc_changed(string action);
36
36
  public signal void action_file_changed(File file, bool actual);
108
108
  bool has_checked_contents = false;
109
109
  bool has_non_home_contents = false;
110
110
  List<File> homes = new List<File>();
 
111
 
 
112
  List<File> read_error_files = null;
111
113
  
112
114
  bool checked_collection_info = false;
113
115
  bool got_collection_info = false;
169
171
    }
170
172
    catch (Error e) {
171
173
      raise_error(e.message, null);
172
 
      done(false, false);
 
174
      done(false, false, null);
173
175
      return;
174
176
    }
175
177
    this.backend = backend;
187
189
    delete_age = settings.get_int(DELETE_AFTER_KEY);
188
190
 
189
191
    if (!restart())
190
 
      done(false, false);
 
192
      done(false, false, null);
191
193
 
192
194
    if (!backend.is_native()) {
193
195
      Network.get().notify["connected"].connect(network_changed);
384
386
  bool restart()
385
387
  {
386
388
    state = State.NORMAL;
 
389
    read_error_files = null;
387
390
    
388
391
    if (mode == Operation.Mode.INVALID)
389
392
      return false;
515
518
 
516
519
    if (!has_progress_total) {
517
520
      if (!restart())
518
 
        done(false, false);
 
521
        done(false, false, null);
519
522
      return;
520
523
    }
521
524
 
551
554
    }
552
555
    
553
556
    if (!restart())
554
 
      done(false, false);
 
557
      done(false, false, null);
555
558
  }
556
559
 
557
560
  bool cleanup() {
596
599
 
597
600
  void handle_done(DuplicityInstance? inst, bool success, bool cancelled)
598
601
  {
 
602
    string detail = null;
 
603
 
599
604
    if (can_ignore_error())
600
605
      success = true;
601
606
 
667
672
          }
668
673
        }
669
674
        else if (mode == Operation.Mode.BACKUP) {
 
675
          if (read_error_files != null) {
 
676
            // OK, we succeeded yay!  But some files didn't make it into the backup
 
677
            // because we couldn't read them.  So tell the user so they don't think
 
678
            // everything is hunky dory.
 
679
            detail = _("Could not back up the following files.  Please make sure you are able to open them.");
 
680
            detail += "\n";
 
681
            foreach (File f in read_error_files) {
 
682
              detail += "\n%s".printf(f.get_parse_name());
 
683
            }
 
684
          }
 
685
 
670
686
          mode = Operation.Mode.INVALID; // mark 'done' so when we delete, we don't restart
671
687
          if (delete_files_if_needed())
672
688
            return;
682
698
    
683
699
    if (!success && !cancelled && !error_issued)
684
700
      show_error(_("Failed with an unknown error."));
685
 
    
 
701
 
686
702
    inst = null;
687
 
    done(success, cancelled);
 
703
    done(success, cancelled, detail);
688
704
  }
689
705
  
690
706
  string saved_status;
803
819
  protected static const int WARNING_UNMATCHED_SIG = 4;
804
820
  protected static const int WARNING_INCOMPLETE_BACKUP = 5;
805
821
  protected static const int WARNING_ORPHANED_BACKUP = 6;
 
822
  protected static const int WARNING_CANNOT_READ = 10;
806
823
  protected static const int DEBUG_GENERIC = 1;
807
824
 
808
825
  void delete_cache()
1265
1282
        // in ourselves, we may never get to it.
1266
1283
        if (mode == Operation.Mode.BACKUP && !this.cleaned_up_once)
1267
1284
          cleanup(); // stops current backup, cleans up, then resumes
1268
 
      break;
 
1285
        break;
 
1286
 
 
1287
      case WARNING_CANNOT_READ:
 
1288
        // A file couldn't be backed up!  We should note the name and present
 
1289
        // the user with a list at the end.
 
1290
        if (firstline.length > 2) {
 
1291
          // Only add it if it's a child of one of our includes.  Sometimes
 
1292
          // Duplicity likes to talk to us about folders like /lost+found and
 
1293
          // such that we don't care about.
 
1294
          var error_file = make_file_obj(firstline[2]);
 
1295
          foreach (File f in includes) {
 
1296
            if (error_file.equal(f) || error_file.has_prefix(f))
 
1297
              read_error_files.append(error_file);
 
1298
          }
 
1299
        }
 
1300
        break;
1269
1301
      }
1270
1302
    }
1271
1303
  }
1406
1438
    }
1407
1439
    catch (Error e) {
1408
1440
      show_error(e.message);
1409
 
      done(false, false);
 
1441
      done(false, false, null);
1410
1442
    }
1411
1443
  }
1412
1444
}