Skip to content
Merged

Pr 2229 #2230

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions keepercommander/importer/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ def register_command_info(aliases, command_info):
help='default shared folder permissions: manage (U)sers, manage (R)ecords, can (E)dit, can (S)hare, or (A)ll, (N)one')
import_parser.add_argument('--update', dest='update_flag', action='store_true',
help='update records with common login, url or title')
import_parser.add_argument('--no-shortcuts', dest='no_shortcuts', action='store_true',
help='disable shortcut handling (only new records)')
import_parser.add_argument('--users', dest='users_only', action='store_true',
help='update shared folder user permissions only')
import_parser.add_argument('--record-type', dest='record_type', action='store',
Expand Down
7 changes: 4 additions & 3 deletions keepercommander/importer/imp_exp.py
Original file line number Diff line number Diff line change
Expand Up @@ -721,6 +721,7 @@ def _import(params, file_format, filename, **kwargs):
if import_into:
import_into = import_into.replace(PathDelimiter, 2*PathDelimiter)
update_flag = kwargs.get('update_flag') or False
no_shortcuts = kwargs.get('no_shortcuts') or False

importer = importer_for_format(file_format)() # type: BaseImporter

Expand Down Expand Up @@ -883,7 +884,7 @@ def _import(params, file_format, filename, **kwargs):
records_v3_to_update = [] # type: List[record_pb2.RecordUpdate]
import_uids = {}

records_to_import, record_exists, external_lookup = prepare_record_add_or_update(update_flag, params, records)
records_to_import, record_exists, external_lookup = prepare_record_add_or_update(update_flag, no_shortcuts, params, records)
if show_skipped and record_exists:
for existing_record in record_exists:
folder_name = ''
Expand Down Expand Up @@ -2063,7 +2064,7 @@ def build_record_hash(tokens): # type: (Iterator[str]) -> str
return hasher.hexdigest()


def prepare_record_add_or_update(update_flag, params, records):
def prepare_record_add_or_update(update_flag, no_shortcuts, params, records):
# type: (bool, KeeperParams, Iterable[ImportRecord]) -> Tuple[List[ImportRecord], List[ImportRecord], dict]
"""
Find what records to import or update.
Expand Down Expand Up @@ -2121,7 +2122,7 @@ def prepare_record_add_or_update(update_flag, params, records):
f.value = LARGE_FIELD_MSG.format(atta.name)

record_hash = build_record_hash(tokenize_full_import_record(import_record))
if record_hash in preexisting_entire_record_hash:
if no_shortcuts is False and record_hash in preexisting_entire_record_hash:
record_uid = preexisting_entire_record_hash[record_hash]
if import_record.uid:
external_lookup[import_record.uid] = record_uid
Expand Down