Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision a051b91b

Von Martin Helmling martin.helmling@octosoft.eu vor mehr als 7 Jahren hinzugefügt

  • ID a051b91b24b34b5586761b237b5eda38e8c83f92
  • Vorgänger 56371b77
  • Nachfolger a33ef0ec

Filemanagement: DEBUG2 herausgenommen

Unterschiede anzeigen:

SL/Controller/File.pm
140 140
    $self->js->flash('error',$::locale->text('File not exists !'))->render();
141 141
    return;
142 142
  }
143
  $main::lxdebug->message(LXDebug->DEBUG2(), "object_id=".$file->object_id." object_type=".$file->object_type." dbfile=".$file);
144 143
  my $sessionfile = $::form->{sessionfile};
145
      $main::lxdebug->message(LXDebug->DEBUG2(), "sessionfile=".$sessionfile);
146 144
  if ( $sessionfile && -f $sessionfile ) {
147
     $main::lxdebug->message(LXDebug->DEBUG2(), "file=".$file->file_name." to=".$::form->{to}." sessionfile=".$sessionfile);
148 145
    # new uploaded file
149 146
    if ( $::form->{to} eq $file->file_name ) {
150 147
      # no rename so use as new version
......
177 174

  
178 175
    eval {
179 176
      $res = $file->rename($::form->{to});
180
      $main::lxdebug->message(LXDebug->DEBUG2(), "rename result=".$res);
181 177
      1;
182 178
    } or do {
183 179
      $self->js->flash(       'error', t8('internal error (see details)'))
......
222 218
  my ($self) = @_;
223 219

  
224 220
  my $source = 'uploaded';
225
  $main::lxdebug->message(LXDebug->DEBUG2(), "file_upload UPLOAD=".$::form->{ATTACHMENTS}->{uploadfiles});
226 221
  my @existing;
227 222
  if ( $::form->{ATTACHMENTS}->{uploadfiles} ) {
228 223
    my @upfiles = @{ $::form->{ATTACHMENTS}->{uploadfiles} };
229 224
    foreach my $idx (0 .. scalar(@upfiles) - 1) {
230 225
      eval {
231 226
        my $fname = uri_unescape($upfiles[$idx]->{filename});
232
        $main::lxdebug->message(LXDebug->DEBUG2(), "file_upload name=".$fname);
233 227
        ## normalize and find basename
234 228
        # first split with unix rules
235 229
        # after that split with windows rules
......
250 244
          $mime_type = File::MimeInfo::Magic::mimetype($basefile);
251 245
          $mime_type = 'application/octet-stream' if $mime_type eq 'application/pdf' || !$mime_type;
252 246
        }
253
        $main::lxdebug->message(LXDebug->DEBUG2(), "mime_type=".$mime_type);
254 247
        if ( $self->file_type eq 'image' && $self->file_probe_image_type($mime_type, $basefile)) {
255 248
          next;
256 249
        }
......
262 255
                                        file_name     => $basefile,
263 256
                                      );
264 257

  
265
        $main::lxdebug->message(LXDebug->DEBUG2(), "store1 exist=".$existobj);
266 258
        if ($existobj) {
267
  $main::lxdebug->message(LXDebug->DEBUG2(), "id=".$existobj->id." sessionfile=". $sfile->file_name);
268 259
          push @existing, $existobj->id.'_'.$sfile->file_name;
269 260
        } else {
270 261
          my $fileobj = SL::File->save(object_id     => $self->object_id,
......
277 268
                                       #file_contents => ${$upfiles[$idx]->{data}},
278 269
                                       file_path     => $sfile->file_name
279 270
                                     );
280
          $main::lxdebug->message(LXDebug->DEBUG2(), "obj=".$fileobj);
281 271
          unlink($sfile->file_name);
282 272
        }
283 273
        1;
......
338 328
  $self->object_id($id);
339 329
  $self->object_model($file_types{$type}->{model});
340 330
  $self->object_right($file_types{$type}->{right});
341
  $main::lxdebug->message(LXDebug->DEBUG2(), "checked: object_id=".$self->object_id." object_type=".$self->object_type." is_global=".$self->is_global);
342 331

  
343 332
 # $::auth->assert($self->object_right);
344 333

  
......
371 360
sub _do_list {
372 361
  my ($self,$json) = @_;
373 362
  my @files;
374
  $main::lxdebug->message(LXDebug->DEBUG2(), "do_list: object_id=".$self->object_id." object_type=".$self->object_type." file_type=".$self->file_type." json=".$json);
375 363
  if ( $self->file_type eq 'document' ) {
376 364
    my @object_types;
377 365
    push @object_types, $self->object_type;
......
380 368
                                          object_type => \@object_types,
381 369
                                          file_type   => $self->file_type  );
382 370

  
383
    $main::lxdebug->message(LXDebug->DEBUG2(), "cnt1=".scalar(@files));
384 371
  }
385 372
  elsif ( $self->file_type eq 'attachment' ||  $self->file_type eq 'image' ) {
386 373
    @files   = SL::File->get_all(object_id   => $self->object_id  ,
387 374
                                 object_type => $self->object_type,
388 375
                                 file_type   => $self->file_type  );
389
    $main::lxdebug->message(LXDebug->DEBUG2(), "cnt2=".scalar(@files));
390 376
  }
391 377
  $self->files(\@files);
392 378
  $self->_mk_render('file/list',1,0,$json);
......
396 382
  my ($self,$path) = @_;
397 383
  my @foundfiles ;
398 384

  
399
  $main::lxdebug->message(LXDebug->DEBUG2(), "import path=".$path);
400 385
  my $language = $::lx_office_conf{system}->{language};
401 386
  my $timezone = $::locale->get_local_time_zone()->name;
402 387
  if (opendir my $dir, $path) {
......
404 389
    foreach my $file ( @files) {
405 390
      next if (($file eq '.') || ($file eq '..'));
406 391
      $file = Encode::decode('utf-8', $file);
407
      $main::lxdebug->message(LXDebug->DEBUG2(), "file=".$file);
408 392

  
409 393
      next if( -d "$path/$file");
410 394

  
411 395
      my $tmppath = File::Spec->catfile( $path, $file );
412
      $main::lxdebug->message(LXDebug->DEBUG2(), "tmppath=".$tmppath." file=".$file);
413 396
      next if( ! -f $tmppath);
414 397

  
415 398
      my $st = stat($tmppath);
......
425 408

  
426 409
    }
427 410
  }
428
  $main::lxdebug->message(LXDebug->DEBUG2(), "return ".scalar(@foundfiles)." files");
429 411
  return @foundfiles;
430 412
}
431 413

  
......
436 418
    ##TODO  here a configurable code must be implemented
437 419

  
438 420
    my $title;
439
    $main::lxdebug->message(LXDebug->DEBUG2(), "mk_render: object_id=".$self->object_id." object_type=".$self->object_type.
440
                              " file_type=".$self->file_type." json=".$json." filecount=".scalar(@{ $self->files })." is_global=".$self->is_global);
441 421
    my @sources = $self->_get_sources();
442 422
    foreach my $source ( @sources ) {
443
      $main::lxdebug->message(LXDebug->DEBUG2(), "mk_render: source name=".$source->{name});
444 423
      @{$source->{files}} = grep { $_->source eq $source->{name}} @{ $self->files };
445 424
    }
446 425
    if ( $self->file_type eq 'document' ) {
......
467 446
      if ( $self->existing && scalar(@{$self->existing}) > 0) {
468 447
        my $first = shift @{$self->existing};
469 448
        my ($first_id,$sfile) = split('_',$first,2);
470
        #$main::lxdebug->message(LXDebug->DEBUG2(), "id=".$first_id." sessionfile=". $sfile);
471 449
        my $file = SL::File->get(id => $first_id );
472 450
        $self->js->run('kivi.File.askForRename',$first_id,$file->file_name,$sfile,join (',', @{$self->existing}), $self->is_global);
473 451
      }
......
490 468
sub _get_sources {
491 469
  my ($self) = @_;
492 470
  my @sources;
493
  $main::lxdebug->message(LXDebug->DEBUG2(), "get_sources file_type=". $self->file_type);
494 471
  if ( $self->file_type eq 'document' ) {
495 472
    ##TODO statt gen neue attribute in filetypes :
496 473
    if (($file_types{$self->object_type}->{gen}*1 & 1)==1) {
......
510 487
    }
511 488
    if (($file_types{$self->object_type}->{gen}*1 & 2)==2) {
512 489
      my @others =  SL::File->get_other_sources();
513
      $main::lxdebug->message(LXDebug->DEBUG2(), "other cnt=". scalar(@others));
514 490
      foreach my $scanner_or_mailrx (@others) {
515 491
        my $other = {
516 492
          'name'         => $scanner_or_mailrx->{name},
......
567 543
    };
568 544
    push @sources , $attdata;
569 545
  }
570
  $main::lxdebug->message(LXDebug->DEBUG2(), "get_sources count=".scalar(@sources));
571 546
  return @sources;
572 547
}
573 548

  
SL/File/Backend/Filesystem.pm
14 14

  
15 15
sub delete {
16 16
  my ($self, %params) = @_;
17
  $main::lxdebug->message(LXDebug->DEBUG2(), "del in backend " . $self . "  file " . $params{dbfile});
18
  $main::lxdebug->message(LXDebug->DEBUG2(), "file id=" . ($params{dbfile}->id * 1));
19
  $main::lxdebug->message(LXDebug->DEBUG2(), "last=" .  $params{last}." all_bnl=". $params{all_but_notlast});
20 17
  die "no dbfile in backend delete" unless $params{dbfile};
21 18
  my $backend_data = $params{dbfile}->backend_data;
22 19
  $backend_data    = 0                               if $params{last};
23 20
  $backend_data    = $params{dbfile}->backend_data-1 if $params{all_but_notlast};
24 21

  
25 22
  if ($backend_data > 0 ) {
26
    $main::lxdebug->message(LXDebug->DEBUG2(), "backend_data=" .$backend_data);
27 23
    for my $version ( 1..$backend_data) {
28 24
      my $file_path = $self->_filesystem_path($params{dbfile},$version);
29
      $main::lxdebug->message(LXDebug->DEBUG2(), "unlink " .$file_path);
30 25
      unlink($file_path);
31 26
    }
32 27
    if ($params{all_but_notlast}) {
......
39 34
      $params{dbfile}->backend_data(0);
40 35
      my $dir_path = $self->_filesystem_path($params{dbfile});
41 36
      rmdir($dir_path);
42
      $main::lxdebug->message(LXDebug->DEBUG2(), "rmdir " .$dir_path);
43 37
    }
44 38
  } else {
45 39
    my $file_path = $self->_filesystem_path($params{dbfile},$params{dbfile}->backend_data);
......
83 77
sub get_mtime {
84 78
  my ($self, %params) = @_;
85 79
  die "no dbfile" unless $params{dbfile};
86
  $main::lxdebug->message(LXDebug->DEBUG2(), "version=" .$params{version});
87 80
  die "unknown version" if $params{version} &&
88 81
                          ($params{version} < 0 || $params{version} > $params{dbfile}->backend_data) ;
89 82
  my $path = $self->_filesystem_path($params{dbfile},$params{version});
90 83
  die "no file found in backend get_mtime" if !-f $path;
91 84
  my @st = stat($path);
92 85
  my $dt = DateTime->from_epoch(epoch => $st[9])->clone();
93
  $main::lxdebug->message(LXDebug->DEBUG2(), "dt=" .$dt);
94 86
  return $dt;
95 87
}
96 88

  
......
131 123
  $version    = $dbfile->backend_data if !$version || $version < 1 || $version > $dbfile->backend_data;
132 124
  my $iddir   = sprintf("%04d", $dbfile->id % 1000);
133 125
  my $path    = File::Spec->catdir($::lx_office_conf{paths}->{document_path}, $::auth->client->{id}, $iddir, $dbfile->id);
134
  $main::lxdebug->message(LXDebug->DEBUG2(), "file path=" .$path." id=" .$dbfile->id." version=".$version." basename=".$dbfile->id . '_' . $version);
135 126
  if (!-d $path) {
136 127
    File::Path::make_path($path, { chmod => 0770 });
137 128
  }

Auch abrufbar als: Unified diff