comparison sat/memory/memory.py @ 3361:43e60c40de65

core (memory/memory): fixed directory creation in setFile
author Goffi <goffi@goffi.org>
date Thu, 17 Sep 2020 21:40:23 +0200
parents b14e95f7034f
children d24252df91ee
comparison
equal deleted inserted replaced
3360:57afccb91961 3361:43e60c40de65
1566 empty string for current version or when there is no versioning 1566 empty string for current version or when there is no versioning
1567 @param parent(unicode, None): id of the directory containing the files 1567 @param parent(unicode, None): id of the directory containing the files
1568 @param path(unicode, None): virtual path of the file in the namespace 1568 @param path(unicode, None): virtual path of the file in the namespace
1569 if set, parent must be None. All intermediate directories will be created 1569 if set, parent must be None. All intermediate directories will be created
1570 if needed, using current access. 1570 if needed, using current access.
1571 @param type_(str, None): type of file filter, can be one of C.FILE_TYPE_*
1571 @param file_hash(unicode): unique hash of the payload 1572 @param file_hash(unicode): unique hash of the payload
1572 @param hash_algo(unicode): algorithm used for hashing the file (usually sha-256) 1573 @param hash_algo(unicode): algorithm used for hashing the file (usually sha-256)
1573 @param size(int): size in bytes 1574 @param size(int): size in bytes
1574 @param namespace(unicode, None): identifier (human readable is better) to group 1575 @param namespace(unicode, None): identifier (human readable is better) to group
1575 files 1576 files
1621 if created is None: 1622 if created is None:
1622 created = time.time() 1623 created = time.time()
1623 if namespace is not None: 1624 if namespace is not None:
1624 namespace = namespace.strip() or None 1625 namespace = namespace.strip() or None
1625 if type_ == C.FILE_TYPE_DIRECTORY: 1626 if type_ == C.FILE_TYPE_DIRECTORY:
1626 if any(version, file_hash, size, mime_type): 1627 if any((version, file_hash, size, mime_type)):
1627 raise ValueError( 1628 raise ValueError(
1628 "version, file_hash, size and mime_type can't be set for a directory" 1629 "version, file_hash, size and mime_type can't be set for a directory"
1629 ) 1630 )
1630 if owner is not None: 1631 if owner is not None:
1631 owner = owner.userhostJID() 1632 owner = owner.userhostJID()