Skip to content

Commit

Permalink
WIP on #34.
Browse files Browse the repository at this point in the history
  • Loading branch information
mjordan committed Aug 3, 2021
1 parent 5bdb085 commit 51bad9d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
4 changes: 4 additions & 0 deletions workbench
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,10 @@ def create():
if custom_field == 'media_use_tid':
continue

# 'checksum' is a reserved CSV field.
if custom_field == 'checksum':
continue

# Execute field preprocessor scripts, if any are configured. Note that these scripts
# are applied to the entire value from the CSV field and not split field values,
# e.g., if a field is multivalued, the preprocesor must split it and then reassemble
Expand Down
9 changes: 8 additions & 1 deletion workbench_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -677,7 +677,7 @@ def check_input(config, args):
base_fields = ['title', 'status', 'promote', 'sticky', 'uid', 'created']
# Any new reserved columns introduced into the CSV need to be removed here. 'langcode' is a standard Drupal field
# but it doesn't show up in any field configs.
reserved_fields = [config['id_field'], 'file', 'media_use_tid', 'node_id', 'url_alias', 'image_alt_text', 'parent_id', 'langcode']
reserved_fields = [config['id_field'], 'file', 'media_use_tid', 'checksum', 'node_id', 'url_alias', 'image_alt_text', 'parent_id', 'langcode']

# Check the config file.
tasks = [
Expand Down Expand Up @@ -1892,6 +1892,13 @@ def create_file(config, filename, file_fieldname, node_csv_row):
print("Warning: local and Drupal checksums for '" + file_path + "' do not match. See the log for more detail.")
logging.warning('Local and Drupal %s checksums for file "%s" (named in CSV row "%s") do not match (local: %s, Drupal: %s).',
config['fixity_algorithm'], file_path, node_csv_row[config['id_field']], hash_from_local, hash_from_drupal)
if 'checksum' in node_csv_row:
if hash_from_local == node_csv_row['checksum'].strip():
logging.info('Local %s checksum and value in the CSV "checksum" field for file "%s" (%s) match.', config['fixity_algorithm'], file_path, hash_from_local)
else:
print("Warning: local checksum and value in CSV for '" + file_path + "' do not match. See the log for more detail.")
logging.warning('Local %s checksum and value in the CSV "checksum" field for file "%s" (named in CSV row "%s") do not match (local: %s, CSV: %s).',
config['fixity_algorithm'], file_path, node_csv_row[config['id_field']], hash_from_local, node_csv_row['checksum'])
if is_remote and config['delete_tmp_upload'] is True:
containing_folder = os.path.join(config['input_dir'], re.sub('[^A-Za-z0-9]+', '_', node_csv_row[config['id_field']]))
shutil.rmtree(containing_folder)
Expand Down

0 comments on commit 51bad9d

Please sign in to comment.