Revision: 25220 http://sourceforge.net/p/bibdesk/svn/25220 Author: hofman Date: 2020-12-20 00:30:12 +0000 (Sun, 20 Dec 2020) Log Message: ----------- Get alias data after relative path, so we can try only once in case relative path is missing
Modified Paths: -------------- trunk/bibdesk/BDSKLinkedFile.m Modified: trunk/bibdesk/BDSKLinkedFile.m =================================================================== --- trunk/bibdesk/BDSKLinkedFile.m 2020-12-19 23:46:57 UTC (rev 25219) +++ trunk/bibdesk/BDSKLinkedFile.m 2020-12-20 00:30:12 UTC (rev 25220) @@ -419,6 +419,8 @@ - (void)encodeWithCoder:(NSCoder *)coder { + // make sure the fileRef is valid + [self URL]; NSData *data = [self aliasDataRelativeToPath:[delegate basePathForLinkedFile:self]]; if ([coder allowsKeyedCoding]) { [coder encodeObject:data forKey:ALIASDATA_KEY]; @@ -446,6 +448,8 @@ - (id)copyWithZone:(NSZone *)aZone { + // make sure the fileRef is valid + [self URL]; NSData *data = [self aliasDataRelativeToPath:[delegate basePathForLinkedFile:self]]; BOOL isBookmarkData = NO; if (data == nil && isBookmark && locator.bookmark){ @@ -608,11 +612,6 @@ - (NSData *)aliasDataRelativeToPath:(NSString *)basePath; { - // make sure the fileRef is valid - [self URL]; - // not sure if this is still needed after the previous call, only does something when there was a valid fileRef, relativePath, and baseRef, then it updates - [self updateFileRef]; - FSRef baseRef; AliasHandle anAlias = NULL; NSData *data = nil; @@ -638,15 +637,17 @@ BOOL noAlias = saveRelativePathOnly && newBasePath != nil; if (newBasePath == nil) newBasePath = [delegate basePathForLinkedFile:self]; - NSData *data = noAlias ? nil : [self aliasDataRelativeToPath:newBasePath]; + // this will make sure the fileRef is valid NSString *path = [self path]; + NSData *data = nil; NSString *dataKey = ALIASDATA_KEY; path = path && newBasePath ? [path relativePathFromPath:newBasePath] : relativePath; - if (path == nil && noAlias) + if (noAlias == NO || path == nil) { data = [self aliasDataRelativeToPath:newBasePath]; - if (data == nil && (noAlias == NO || path == nil) && isBookmark) { - data = locator.bookmark; - dataKey = BOOKMARK_KEY; + if (data == nil && isBookmark) { + data = locator.bookmark; + dataKey = BOOKMARK_KEY; + } } NSDictionary *dictionary = data ? [NSDictionary dictionaryWithObjectsAndKeys:data, dataKey, path, RELATIVEPATH_KEY, nil] : [NSDictionary dictionaryWithObjectsAndKeys:path, RELATIVEPATH_KEY, nil]; if (saveArchivedData) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. _______________________________________________ Bibdesk-commit mailing list Bibdesk-commit@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/bibdesk-commit