From d5514a07ad8470e0c00f158ef0a02ff6a90adb22 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sat, 4 Jul 2009 16:42:12 +0100 Subject: [PATCH] Use .tmp for temporary files and write-then-rename --- pctb/Makefile | 6 ++++-- pctb/README | 4 ++-- pctb/commod-results-processor | 4 ++-- pctb/dictionary-manager | 4 ++-- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/pctb/Makefile b/pctb/Makefile index 9daeddb..af0901b 100644 --- a/pctb/Makefile +++ b/pctb/Makefile @@ -44,7 +44,9 @@ $(CONVERT_OBJS): ocr.h convert.h structure.h common.h clean: rm -f *.o core core.* *~ vgcore.* - rm -f t t.* u u.* v v.* + rm -f t t.* u u.* v v.* *.tmp realclean: clean - rm -f $(TARGETS) ./#pages#.ppm + rm -f $(TARGETS) + rm -f ./#pages#.ppm ./#upload-*#.txt ./#commodmap#.tsv + rm -f ./#master-*#.txt ./#local-*#.txt diff --git a/pctb/README b/pctb/README index 4f56fd8..9691433 100644 --- a/pctb/README +++ b/pctb/README @@ -126,10 +126,10 @@ The program reads and writes the following files: HTML returned from the upload server is left in these dropping files for debugging etc. - * .new + * .tmp When any of these tools overwrite one of the persistent dictionary - files, they temporarily write to .new. + files, they temporarily write to .tmp. These files are all in the current working directory. There is not yet any feature to have them be somewhere else. The helper programs diff --git a/pctb/commod-results-processor b/pctb/commod-results-processor index cea64e5..3ea53be 100755 --- a/pctb/commod-results-processor +++ b/pctb/commod-results-processor @@ -244,7 +244,7 @@ sub refresh_commodmap() { my $incommodmap=0; my $intag=''; my %got; - my $o= new IO::File "#commodmap#.tsv.new",'w' or die $!; + my $o= new IO::File "#commodmap#.tsv.tmp",'w' or die $!; undef %commodmap; my $xp= new XML::Parser @@ -292,7 +292,7 @@ sub refresh_commodmap() { # print STDERR "[[[$content]]]\n"; $xp->parse($content); close $o or die $!; - rename "#commodmap#.tsv.new","#commodmap#.tsv" or die $!; + rename "#commodmap#.tsv.tmp","#commodmap#.tsv" or die $!; } our %newcommods; diff --git a/pctb/dictionary-manager b/pctb/dictionary-manager index 9cbdb78..5079def 100755 --- a/pctb/dictionary-manager +++ b/pctb/dictionary-manager @@ -225,7 +225,7 @@ proc write_database {} { global reqkind database_fn database upvar #0 database_magic/$reqkind magic - set f [open $database_fn.new w] + set f [open $database_fn.tmp w] puts $f $magic write_database_header/$reqkind $f @@ -239,7 +239,7 @@ proc write_database {} { } puts $f "." close $f - file rename -force $database_fn.new $database_fn + file rename -force $database_fn.tmp $database_fn } proc select_database {dbname_spec} { -- 2.30.2