Bug fix for keywords, persons in deleted photos

This commit is contained in:
Rhet Turnbull 2020-07-04 09:54:43 -07:00
parent 80f5989e2c
commit df75a05645
26 changed files with 59 additions and 21 deletions

View File

@ -1,3 +1,3 @@
""" version info """
__version__ = "0.30.6"
__version__ = "0.30.7"

View File

@ -541,7 +541,7 @@ class PhotosDB:
""" select RKPerson.name, RKVersion.uuid from RKFace, RKPerson, RKVersion, RKMaster
where RKFace.personID = RKperson.modelID and RKVersion.modelId = RKFace.ImageModelId
and RKVersion.masterUuid = RKMaster.uuid
and RKVersion.isInTrash = 0 """
"""
)
for person in c:
if person[0] is None:
@ -561,7 +561,7 @@ class PhotosDB:
from RKAlbum, RKVersion, RKAlbumVersion
where RKAlbum.modelID = RKAlbumVersion.albumId and
RKAlbumVersion.versionID = RKVersion.modelId
and RKVersion.isInTrash = 0 """
"""
)
for album in c:
# store by uuid in _dbalbums_uuid and by album in _dbalbums_album
@ -680,12 +680,17 @@ class PhotosDB:
# Get info on keywords
c.execute(
""" select RKKeyword.name, RKVersion.uuid, RKMaster.uuid from
""" SELECT
RKKeyword.name,
RKVersion.uuid,
RKMaster.uuid
FROM
RKKeyword, RKKeywordForVersion, RKVersion, RKMaster
where RKKeyword.modelId = RKKeyWordForVersion.keywordID and
RKVersion.modelID = RKKeywordForVersion.versionID and
RKMaster.uuid = RKVersion.masterUuid and
RKVersion.isInTrash = 0 """
WHERE
RKKeyword.modelId = RKKeyWordForVersion.keywordID AND
RKVersion.modelID = RKKeywordForVersion.versionID AND
RKMaster.uuid = RKVersion.masterUuid
"""
)
for keyword in c:
if not keyword[1] in self._dbkeywords_uuid:
@ -1750,7 +1755,6 @@ class PhotosDB:
"FROM ZGENERICASSET, ZUNMANAGEDADJUSTMENT "
"JOIN ZADDITIONALASSETATTRIBUTES ON ZADDITIONALASSETATTRIBUTES.ZASSET = ZGENERICASSET.Z_PK "
"WHERE ZADDITIONALASSETATTRIBUTES.ZUNMANAGEDADJUSTMENT = ZUNMANAGEDADJUSTMENT.Z_PK "
"AND ZGENERICASSET.ZTRASHEDSTATE = 0 "
)
for row in c:
uuid = row[0]

View File

@ -7,7 +7,7 @@
<key>hostuuid</key>
<string>9575E48B-8D5F-5654-ABAC-4431B1167324</string>
<key>pid</key>
<integer>763</integer>
<integer>1613</integer>
<key>processname</key>
<string>photolibraryd</string>
<key>uid</key>

Binary file not shown.

After

Width:  |  Height:  |  Size: 524 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 196 KiB

View File

@ -7,9 +7,9 @@ PHOTOS_DB = "tests/Test-10.15.5.photoslibrary/database/photos.db"
PHOTOS_DB_PATH = "/Test-10.15.5.photoslibrary/database/photos.db"
PHOTOS_LIBRARY_PATH = "/Test-10.15.5.photoslibrary"
PHOTOS_DB_LEN = 14
PHOTOS_DB_LEN = 15
PHOTOS_NOT_IN_TRASH_LEN = 13
PHOTOS_IN_TRASH_LEN = 1
PHOTOS_IN_TRASH_LEN = 2
KEYWORDS = [
"Kids",
@ -34,7 +34,7 @@ ALBUMS = [
]
KEYWORDS_DICT = {
"Kids": 4,
"wedding": 2,
"wedding": 3,
"flowers": 1,
"England": 1,
"London": 1,
@ -43,7 +43,7 @@ KEYWORDS_DICT = {
"UK": 1,
"United Kingdom": 1,
}
PERSONS_DICT = {"Katie": 3, "Suzy": 2, "Maria": 1, _UNKNOWN_PERSON: 1}
PERSONS_DICT = {"Katie": 3, "Suzy": 2, "Maria": 2, _UNKNOWN_PERSON: 1}
ALBUM_DICT = {
"Pumpkin Farm": 3,
"Test Album": 2,
@ -71,6 +71,7 @@ UUID_DICT = {
"date_invalid": "8846E3E6-8AC8-4857-8448-E3D025784410",
"intrash": "71E3E212-00EB-430D-8A63-5E294B268554",
"not_intrash": "DC99FBDD-7A52-4100-A5BB-344131646C30",
"intrash_person_keywords": "6FD38366-3BF2-407D-81FE-7153EB6125B6",
}
UUID_PUMPKIN_FARM = [
@ -195,7 +196,7 @@ def test_keywords_dict():
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
keywords = photosdb.keywords_as_dict
assert keywords["wedding"] == 2
assert keywords["wedding"] == 3
assert keywords == KEYWORDS_DICT
@ -204,7 +205,7 @@ def test_persons_as_dict():
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
persons = photosdb.persons_as_dict
assert persons["Maria"] == 1
assert persons["Maria"] == 2
assert persons == PERSONS_DICT
@ -459,7 +460,7 @@ def test_photos_intrash_2():
assert p.intrash
def test_photos_intrash_2():
def test_photos_intrash_3():
""" test PhotosDB.photos(intrash=False) """
import osxphotos
@ -487,6 +488,39 @@ def test_photoinfo_intrash_2():
assert not p
def test_photoinfo_intrash_3():
""" Test PhotoInfo.intrash and photo has keyword and person """
import osxphotos
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
p = photosdb.photos(uuid=[UUID_DICT["intrash_person_keywords"]], intrash=True)[0]
assert p.intrash
assert "Maria" in p.persons
assert "wedding" in p.keywords
def test_photoinfo_intrash_4():
""" Test PhotoInfo.intrash and photo has keyword and person """
import osxphotos
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
p = photosdb.photos(persons=["Maria"], intrash=True)[0]
assert p.intrash
assert "Maria" in p.persons
assert "wedding" in p.keywords
def test_photoinfo_intrash_5():
""" Test PhotoInfo.intrash and photo has keyword and person """
import osxphotos
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
p = photosdb.photos(keywords=["wedding"], intrash=True)[0]
assert p.intrash
assert "Maria" in p.persons
assert "wedding" in p.keywords
def test_photoinfo_not_intrash():
""" Test PhotoInfo.intrash """
import osxphotos
@ -501,7 +535,7 @@ def test_keyword_2():
photosdb = osxphotos.PhotosDB(dbfile=PHOTOS_DB)
photos = photosdb.photos(keywords=["wedding"])
assert len(photos) == 2
assert len(photos) == 2 # won't show the one in the trash
def test_keyword_not_in_album():

View File

@ -211,7 +211,7 @@ PHOTOS_IN_TRASH_LEN_14_6 = 1
PHOTOS_MISSING_14_6 = 1
PHOTOS_NOT_IN_TRASH_LEN_15_5 = 13
PHOTOS_IN_TRASH_LEN_15_5 = 1
PHOTOS_IN_TRASH_LEN_15_5 = 2
PHOTOS_MISSING_15_5 = 2
CLI_PLACES_JSON = """{"places": {"_UNKNOWN_": 1, "Maui, Wailea, Hawai'i, United States": 1, "Washington, District of Columbia, United States": 1}}"""
@ -260,7 +260,7 @@ LABELS_JSON = {
KEYWORDS_JSON = {
"keywords": {
"Kids": 4,
"wedding": 2,
"wedding": 3,
"London 2018": 1,
"St. James's Park": 1,
"England": 1,
@ -283,7 +283,7 @@ ALBUMS_JSON = {
"shared albums": {},
}
PERSONS_JSON = {"persons": {"Katie": 3, "Suzy": 2, "_UNKNOWN_": 1, "Maria": 1}}
PERSONS_JSON = {"persons": {"Katie": 3, "Suzy": 2, "_UNKNOWN_": 1, "Maria": 2}}
# determine if exiftool installed so exiftool tests can be skipped
try: