那麼,這是我在一個漫長的時間裏最怪異的文件系統相關問題。文本文件被不完整地移動到cifs與Perl的掛載點
I have a script,基本上連接遠程IMAP服務器上,下載郵件,將其標記爲已讀,敲竹槓的垃圾,只下載.txt
和.xml
文件。如果.txt
使用Text::Unaccent
刪除重音。
這是在imap遠程文件夾與此服務器上本地安裝的cif文件夾的1對1關係上完成的。刪除imap下載和重音處理工作得很好。
我的問題是:如果我下載文件,處理重音,並將其移到cifs
掛載的目錄,該文件被撕掉(最後4到10K丟失)。如果我將它移動到同一臺機器上的anoter分區上,文件會以一種理智的方式移動(相同的md5sum
,相同的文件大小,不會被diff
注意到)。
的代碼,不會口音刪除和移動文件的塊:
#If file extension = .txt
if ("$temp_dir/$arquivo" =~ /txt$/i){
#Put file line by line inside array
open (LEITURA, "$temp_dir/$arquivo");
@manipular = <LEITURA>;
close LEITURA;
#Open the same file to writing with other filehandler
open (ESCRITA, ">", "$temp_dir/$arquivo");
foreach $manipula_linha (@manipular){
# Removes & and accents
$manipula_linha =~ s/\&/e/g;
$manipula_linha = unac_string("UTF-8", $manipula_linha);
print ESCRITA $manipula_linha;
};
};
# copy temp file to final destination. If cifs = crash
# move also does not work...
copy "$temp_dir/$arquivo", "$dest_file";
unlink "$temp_dir/$arquivo";
CIFS版本:
[[email protected] mail_downloader]# modinfo cifs
filename: /lib/modules/2.6.18-409.el5.centos.plus/kernel/fs/cifs/cifs.ko
version: 1.60RH
description: VFS to access servers complying with the SNIA CIFS Specification e.g. Samba and Windows
license: GPL
Perl版本:
[[email protected] mail_downloader]# perl --version
This is perl, v5.8.8 built for i386-linux-thread-multi
Unaccent版本:
[[email protected] mail_downloader]# rpm -qa | grep Unaccent
perl-Text-Unaccent-1.08-1.2.el5.rf
問題:任何線索爲什麼perl move
或copy
有這種行爲與CIFS掛載點以及如何解決此問題?
顯然我不能在這裏發佈文件內容,因爲他們是EDI相關的東西,並有一些財務信息。
而且,如果我評論perl的copy
處理文件自己unaccent使用cp
或mv
完成後,該文件被正確地移動到cifs
掛載點。
好吧。對我感到羞恥。爲了測試目的,我在其他腳本上寫了這個不起作用的函數,並且我忘記了將'close ESCRITA'移植到這個函數中。猜猜你是對的。 – nwildner
收到帶有4個'.txt'文件的電子郵件後,問題再次複製。我猜它只與文件關閉無關。沒有關於cifs的'dmesg'消息不可用... – nwildner
問題不在於cifs - 它是本地文件系統緩衝寫入。我期望關閉文件會導致它將內容刷新到磁盤,但它聽起來像需要一些幫助。我已經更新了我的答案,並使用了一個可以工作的文件。 –