Project

General

Profile

« Previous | Next » 

Revision 14762

fix: lib/sh/util.sh: already_exists_msg(): changed calling convention to avoid it seeming like `return 0` is run if already_exists_msg() throws an error, when in fact already_exists_msg() is just a command that should be run before returning/errexiting

View differences:

trunk/inputs/GBIF/raw_occurrence_record_plants/run
28 28
 `institution_code` varchar(255) NOT NULL PRIMARY KEY
29 29
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='from IH.vegpath.org?&Index+Herbariorum'
30 30
EOF
31
) || skip_table || return 0
31
) || { skip_table; return 0; }
32 32
	append=1 mysql_import <"$top_dir"/herbaria_filter.ih.csv_
33 33
}
34 34

  
......
45 45
 KEY `plant_fraction` (`plant_fraction`)
46 46
) ENGINE=MyISAM DEFAULT CHARSET=utf8
47 47
EOF
48
) || table=plant_fraction skip_table || return 0
48
) || { table=plant_fraction skip_table; return 0; }
49 49
	mysql <<EOF
50 50
INSERT INTO "plant_fraction"
51 51
SELECT
......
82 82
SELECT * FROM `plant_fraction`
83 83
WHERE plant_fraction >= 0.8
84 84
EOF
85
) || table=plant_fraction_for_herbaria_filter skip_table || return 0
85
) || { table=plant_fraction_for_herbaria_filter skip_table; return 0; }
86 86
}
87 87

  
88 88
herbaria_filter/make() # runtime: ~0 ("0m2.235s"): CSV import, index scans only
......
101 101
 `institution_code` varchar(255) NOT NULL PRIMARY KEY
102 102
) ENGINE=MyISAM DEFAULT CHARSET=utf8
103 103
EOF
104
) || skip_table || return 0
104
) || { skip_table; return 0; }
105 105
	mysql <<EOF
106 106
INSERT IGNORE INTO $table
107 107
SELECT institution_code FROM ih_herbarium
......
137 137
	OR  (family LIKE '%aceae%' OR family IN ('Compositae','Gramineae','Palmae','Guttiferae','Cruciferae','Labiatae','Umbelliferae','Leguminosae'))
138 138
)
139 139
EOF
140
) || skip_table || return 0
140
) || { skip_table; return 0; }
141 141
}
142 142

  
143 143
# table.tsv.gz/upload() runtime: 15 min ("2184253533 100% 2.30MB/s 0:15:03")
trunk/lib/runscripts/table.run
31 31
table_make_install()
32 32
{
33 33
	echo_func
34
	if ! remaking && pg_table_exists; then skip_table || return 0; fi
34
	if ! remaking && pg_table_exists; then skip_table; return 0; fi
35 35
	local install_log="${install_log-$top_dir/$install_log_rel}"
36 36
	local verbosity_min= # install logs require default verbosity
37 37
	if ! remaking && test -e "$install_log"; then local_export noclobber=1; fi
trunk/lib/sh/util.sh
1291 1291

  
1292 1292
#### commands
1293 1293

  
1294
already_exists_msg() # usage: cond || what=... already_exists_msg || return 0
1294
already_exists_msg()
1295
# usage: cond || { save_e; what=_ already_exists_msg; rethrow; } || return 0
1295 1296
{
1296
	save_e # needed because $(mk_hint) resets $?
1297
	type=info die "$what already exists, skipping
1297
	log_info "$what already exists, skipping
1298 1298
$(mk_hint 'to force-remake, prepend `rm=1` to the command')"
1299 1299
}
1300 1300

  
1301 1301
require_not_exists() # usage: require_not_exists file || return 0
1302
{ test ! -e "$1" || what="file \"$1\"" already_exists_msg; }
1302
{ test ! -e "$1" || { save_e; what="file \"$1\"" already_exists_msg; rethrow;} }
1303 1303

  
1304 1304
function to_file() # usage: stdout=... [if_not_exists=1] [del=] to_file cmd...
1305 1305
# auto-removes a command's output file on error (like make's .DELETE_ON_ERROR)
trunk/lib/sh/db.sh
28 28
fi # load new aliases
29 29
if self_being_included; then
30 30

  
31
skip_table() # usage: create_table || table=... skip_table || return 0
31
skip_table() # usage: create_table || { table=... skip_table; return 0; }
32 32
{ what="table $table" already_exists_msg; }
33 33

  
34 34
: "${test=$(isset limit; exit2bool)}" # test mode when using limited # rows

Also available in: Unified diff