[Mew-dist 04414] Re: im-90: imget does not handle database as a folder-name but file-name

Motonori Nakamura motonori at example.com
1998年 4月 16日 (木) 10:32:36 JST


ごめんなさい。
filesystem full だった場合に作られた空ファイルを削除するということを
実現するために変更したところが副作用を引き起こしてしまったようです。

>>>>> On Wed, 15 Apr 1998 15:20:33 +0900, Makoto MATSUSHITA (まつしたまこと) <matusita at example.com> said:

matusita> とりあえず「少なくともこうすれば直ることは直る」という patch 
matusita> を以下に添付します.

代りにこのパッチで良いと思います。unexpand_path は呼ばないようにしました。


*** MsgStore.pm.in-	Tue Apr  7 21:31:41 1998
--- MsgStore.pm.in	Wed Apr 15 22:48:02 1998
***************
*** 69,75 ****
  	$MsgNum = message_number($folder, 'new');
  	if ($MsgNum == 0) {
  	    im_warn("can't get new message number in $folder\n");
! 	    return '';
  	}
  	$First = $Last = $MsgNum;
      } else {
--- 69,75 ----
  	$MsgNum = message_number($folder, 'new');
  	if ($MsgNum == 0) {
  	    im_warn("can't get new message number in $folder\n");
! 	    return ('', '');
  	}
  	$First = $Last = $MsgNum;
      } else {
***************
*** 81,99 ****
  	im_notice("creating file: $file\n");
  	unless ($file) {
  	    # message path allocation failed
! 	    return '';
  	}
  	if (excl_create(\*MESSAGE, $file) == 0) {
  	    # created successfully
  	    $Last = $MsgNum;
! #	    return "$folder/$MsgNum";
! 	    return $file;
  	}
  	$MsgNum++;
      }
      im_warn("excl_create failed.\n");
      # message creation failed
!     return '';
  }
  
  sub store_message ($$) {
--- 81,98 ----
  	im_notice("creating file: $file\n");
  	unless ($file) {
  	    # message path allocation failed
! 	    return ('', '');
  	}
  	if (excl_create(\*MESSAGE, $file) == 0) {
  	    # created successfully
  	    $Last = $MsgNum;
! 	    return ("$folder/$MsgNum", $file);
  	}
  	$MsgNum++;
      }
      im_warn("excl_create failed.\n");
      # message creation failed
!     return ('', '');
  }
  
  sub store_message ($$) {
***************
*** 110,125 ****
  	touch_folder($dst);
  	$PrevDst = $dst;
      }
!     my $file = &new_message(\*ART, $dst);
      my $size = 0;
!     if ($file ne '') {
  	my $line;
  	my $hcount = 0;
  	my $inheader = 1;
  	if (&unixp() && !&no_sync()) {
  	    select (ART); $| = 1; select (STDOUT);
  	}
! 	im_notice("creating $file\n");
  	foreach $line (@$Msg) {
  	    $size += length($line);
  	    if ($line eq "\n") {
--- 109,124 ----
  	touch_folder($dst);
  	$PrevDst = $dst;
      }
!     my ($msgfile, $filepath) = &new_message(\*ART, $dst);
      my $size = 0;
!     if ($filepath ne '') {
  	my $line;
  	my $hcount = 0;
  	my $inheader = 1;
  	if (&unixp() && !&no_sync()) {
  	    select (ART); $| = 1; select (STDOUT);
  	}
! 	im_notice("creating $filepath\n");
  	foreach $line (@$Msg) {
  	    $size += length($line);
  	    if ($line eq "\n") {
***************
*** 127,149 ****
  	    }
  	    $hcount++ if ($inheader);
  	    unless (print ART $line) {
! 		im_err("writing to $file failed ($!).\n");
  		close(ART);
! 		unlink($file) if (-z $file);
  		return -1;
  	    }
  	}
  	if (&unixp() && !&no_sync()) {
  	    if (fsync(fileno(ART)) < 0) {
! 		im_err("writing to $file failed ($!).\n");
  		close(ART);
! 		unlink($file) if (-z $file);
  		return -1;
  	    }
  	}
  	unless (close(ART)) {
! 	    im_err("writing to $file failed ($!).\n");
! 	    unlink($file) if (-z $file);
  	    return -1;
  	}
  
--- 126,148 ----
  	    }
  	    $hcount++ if ($inheader);
  	    unless (print ART $line) {
! 		im_err("writing to $filepath failed ($!).\n");
  		close(ART);
! 		unlink($filepath) if (-z $filepath);
  		return -1;
  	    }
  	}
  	if (&unixp() && !&no_sync()) {
  	    if (fsync(fileno(ART)) < 0) {
! 		im_err("writing to $filepath failed ($!).\n");
  		close(ART);
! 		unlink($filepath) if (-z $filepath);
  		return -1;
  	    }
  	}
  	unless (close(ART)) {
! 	    im_err("writing to $filepath failed ($!).\n");
! 	    unlink($filepath) if (-z $filepath);
  	    return -1;
  	}
  
***************
*** 157,163 ****
  
  #	    $Head{'bytes:'} = $size;
  	    $Head{'kbytes:'} = int(($size + 1023) / 1024);
! 	    ($Head{'number:'} = $file) =~ s/^.*\///;
  	    $Head{'folder:'} = $dst;
  	    &parse_header(\%Head);
  #	    if ($main::opt_thread) {
--- 156,162 ----
  
  #	    $Head{'bytes:'} = $size;
  	    $Head{'kbytes:'} = int(($size + 1023) / 1024);
! 	    ($Head{'number:'} = $msgfile) =~ s/^.*\///;
  	    $Head{'folder:'} = $dst;
  	    &parse_header(\%Head);
  #	    if ($main::opt_thread) {
***************
*** 184,190 ****
  	    require IM::History && import IM::History;
  
  	    unless (history_open(1) < 0) {
! 		history_store($mid, $file);
  		history_store("partial:$master", $mid) if ($master ne '');
  		history_close();
  	    }
--- 183,189 ----
  	    require IM::History && import IM::History;
  
  	    unless (history_open(1) < 0) {
! 		history_store($mid, $msgfile);
  		history_store("partial:$master", $mid) if ($master ne '');
  		history_close();
  	    }
***************
*** 237,243 ****
  #
  sub open_fcc ($$) {
      my ($folder, $dir_style) = @_;
!     my ($fcc_dir, $rm_file_on_error, $fcc_folder, $FILE, $path);
      $fcc_folder = &expand_path($folder);
  
      if (-d $fcc_folder) {
--- 236,242 ----
  #
  sub open_fcc ($$) {
      my ($folder, $dir_style) = @_;
!     my ($fcc_dir, $rm_file_on_error, $fcc_folder, $FILE, $msgfile);
      $fcc_folder = &expand_path($folder);
  
      if (-d $fcc_folder) {
***************
*** 264,270 ****
  	    im_warn("can't write FCC file: $fcc_folder\n");
  	    return undef;
  	}
! 	$path = $folder;
  	$rm_file_on_error = '';
      } else {
  	unless (-d $fcc_folder) {
--- 263,269 ----
  	    im_warn("can't write FCC file: $fcc_folder\n");
  	    return undef;
  	}
! 	$msgfile = $folder;
  	$rm_file_on_error = '';
      } else {
  	unless (-d $fcc_folder) {
***************
*** 273,291 ****
  		return undef;
  	    }
  	}
! 	my $file = &new_message(\*FCC, $fcc_folder);
! 	return undef if ($file eq '');
! 	touch_folder($file);
! 	$rm_file_on_error = $file;
! 	im_debug("FCC storing in $file\n")
  	  if (&debug('fcc'));
- 	$file =~ /(\d+)$/;
- 	$path = "$folder/$1";
      }
      if (&unixp() && !&no_sync()) {
  	select (FCC); $| = 1; select (STDOUT);
      }
!     return (\*FCC, $fcc_dir, $path, $rm_file_on_error);
  }
  
  # excl_create(handle, file)
--- 272,287 ----
  		return undef;
  	    }
  	}
! 	($msgfile, $rm_file_on_error) = &new_message(\*FCC, $fcc_folder);
! 	return undef if ($msgfile eq '');
! 	touch_folder($msgfile);
! 	im_debug("FCC storing in $rm_file_on_error\n")
  	  if (&debug('fcc'));
      }
      if (&unixp() && !&no_sync()) {
  	select (FCC); $| = 1; select (STDOUT);
      }
!     return (\*FCC, $fcc_dir, $msgfile, $rm_file_on_error);
  }
  
  # excl_create(handle, file)


- motonori



Mew-dist メーリングリストの案内