chore(tool): fix rename-user in single store mode
parent
694ffa74ba
commit
946419f434
|
@ -413,6 +413,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) _updateLocalACLsForPath: (NSString *) path
|
- (void) _updateLocalACLsForPath: (NSString *) path
|
||||||
|
andFolderID: (NSString *) folderID
|
||||||
fromSQLUser: (NSString *) sqlFromUserID
|
fromSQLUser: (NSString *) sqlFromUserID
|
||||||
toSQLUser: (NSString *) sqlToUserID
|
toSQLUser: (NSString *) sqlToUserID
|
||||||
{
|
{
|
||||||
|
@ -443,6 +444,10 @@
|
||||||
sqlToUserID, rest];
|
sqlToUserID, rest];
|
||||||
location = [folder aclLocation];
|
location = [folder aclLocation];
|
||||||
ac = [cm acquireOpenChannelForURL: location];
|
ac = [cm acquireOpenChannelForURL: location];
|
||||||
|
if ([GCSFolderManager singleStoreMode])
|
||||||
|
sql = [NSString stringWithFormat: @"UPDATE %@ SET c_object = '%@' WHERE c_folder_id = %@",
|
||||||
|
[location gcsTableName], newObjectPath, folderID];
|
||||||
|
else
|
||||||
sql = [NSString stringWithFormat: @"UPDATE %@ SET c_object = '%@'",
|
sql = [NSString stringWithFormat: @"UPDATE %@ SET c_object = '%@'",
|
||||||
[location gcsTableName], newObjectPath];
|
[location gcsTableName], newObjectPath];
|
||||||
[ac evaluateExpressionX: sql];
|
[ac evaluateExpressionX: sql];
|
||||||
|
@ -470,36 +475,47 @@
|
||||||
sqlFromUserID = [fromUserID asSafeSQLString];
|
sqlFromUserID = [fromUserID asSafeSQLString];
|
||||||
sqlToUserID = [toUserID asSafeSQLString];
|
sqlToUserID = [toUserID asSafeSQLString];
|
||||||
|
|
||||||
sql = [NSString stringWithFormat: @"SELECT c_path FROM %@"
|
sql = [NSString stringWithFormat: @"SELECT c_path, c_folder_id FROM %@"
|
||||||
@" WHERE c_path2 = '%@'",
|
@" WHERE c_path2 = '%@'",
|
||||||
[folderLocation gcsTableName], sqlToUserID];
|
[folderLocation gcsTableName], sqlToUserID];
|
||||||
[fc evaluateExpressionX: sql];
|
[fc evaluateExpressionX: sql];
|
||||||
attrs = [fc describeResults: NO];
|
attrs = [fc describeResults: NO];
|
||||||
while ((row = [fc fetchAttributes: attrs withZone: NULL]))
|
while ((row = [fc fetchAttributes: attrs withZone: NULL]))
|
||||||
[self _updateLocalACLsForPath: [row objectForKey: @"c_path"]
|
[self _updateLocalACLsForPath: [row objectForKey: @"c_path"]
|
||||||
|
andFolderID: [row objectForKey: @"c_folder_id"]
|
||||||
fromSQLUser: sqlFromUserID
|
fromSQLUser: sqlFromUserID
|
||||||
toSQLUser: sqlToUserID];
|
toSQLUser: sqlToUserID];
|
||||||
[fc cancelFetch];
|
[fc cancelFetch];
|
||||||
[cm releaseChannel: fc immediately: YES];
|
[cm releaseChannel: fc immediately: YES];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) _updateForeignACLsForLocation: (NSString *) locationString
|
- (void) _updateForeignACLsForPath: (NSString *) path
|
||||||
|
andFolderID: (NSString *) folderID
|
||||||
fromSQLUser: (NSString *) sqlFromUserID
|
fromSQLUser: (NSString *) sqlFromUserID
|
||||||
toSQLUser: (NSString *) sqlToUserID
|
toSQLUser: (NSString *) sqlToUserID
|
||||||
{
|
{
|
||||||
NSAutoreleasePool *pool;
|
|
||||||
NSURL *location;
|
|
||||||
GCSChannelManager *cm;
|
GCSChannelManager *cm;
|
||||||
|
GCSFolder *folder;
|
||||||
|
GCSFolderManager *fm;
|
||||||
EOAdaptorChannel *tc;
|
EOAdaptorChannel *tc;
|
||||||
|
NSAutoreleasePool *pool;
|
||||||
NSString *sql;
|
NSString *sql;
|
||||||
|
NSURL *location;
|
||||||
|
|
||||||
pool = [NSAutoreleasePool new];
|
pool = [NSAutoreleasePool new];
|
||||||
|
|
||||||
cm = [[GCSFolderManager defaultFolderManager] channelManager];
|
fm = [GCSFolderManager defaultFolderManager];
|
||||||
|
cm = [fm channelManager];
|
||||||
location = [NSURL URLWithString: locationString];
|
folder = [fm folderAtPath: path];
|
||||||
|
location = [folder aclLocation];
|
||||||
|
|
||||||
tc = [cm acquireOpenChannelForURL: location];
|
tc = [cm acquireOpenChannelForURL: location];
|
||||||
|
if ([GCSFolderManager singleStoreMode])
|
||||||
|
sql = [NSString stringWithFormat: @"UPDATE %@ SET c_uid = '%@'"
|
||||||
|
@" WHERE c_uid = '%@'",
|
||||||
|
[location gcsTableName],
|
||||||
|
sqlToUserID, sqlFromUserID];
|
||||||
|
else
|
||||||
sql = [NSString stringWithFormat: @"UPDATE %@ SET c_uid = '%@'"
|
sql = [NSString stringWithFormat: @"UPDATE %@ SET c_uid = '%@'"
|
||||||
@" WHERE c_uid = '%@'",
|
@" WHERE c_uid = '%@'",
|
||||||
[location gcsTableName],
|
[location gcsTableName],
|
||||||
|
@ -527,13 +543,14 @@
|
||||||
sqlFromUserID = [fromUserID asSafeSQLString];
|
sqlFromUserID = [fromUserID asSafeSQLString];
|
||||||
sqlToUserID = [toUserID asSafeSQLString];
|
sqlToUserID = [toUserID asSafeSQLString];
|
||||||
|
|
||||||
sql = [NSString stringWithFormat: @"SELECT c_acl_location FROM %@"
|
sql = [NSString stringWithFormat: @"SELECT c_path, c_folder_id FROM %@"
|
||||||
@" WHERE c_path2 != '%@'",
|
@" WHERE c_path2 != '%@'",
|
||||||
[folderLocation gcsTableName], sqlToUserID];
|
[folderLocation gcsTableName], sqlToUserID];
|
||||||
[fc evaluateExpressionX: sql];
|
[fc evaluateExpressionX: sql];
|
||||||
attrs = [fc describeResults: NO];
|
attrs = [fc describeResults: NO];
|
||||||
while ((row = [fc fetchAttributes: attrs withZone: NULL]))
|
while ((row = [fc fetchAttributes: attrs withZone: NULL]))
|
||||||
[self _updateForeignACLsForLocation: [row objectForKey: @"c_acl_location"]
|
[self _updateForeignACLsForPath: [row objectForKey: @"c_path"]
|
||||||
|
andFolderID: [row objectForKey: @"c_folder_id"]
|
||||||
fromSQLUser: sqlFromUserID
|
fromSQLUser: sqlFromUserID
|
||||||
toSQLUser: sqlToUserID];
|
toSQLUser: sqlToUserID];
|
||||||
[fc cancelFetch];
|
[fc cancelFetch];
|
||||||
|
|
Loading…
Reference in New Issue