Changeset 2709
- Timestamp:
- 27/08/2010 10:24:44 (18 months ago)
- File:
-
- 1 edited
-
box/trunk/bin/bbstoreaccounts/bbstoreaccounts.cpp (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
box/trunk/bin/bbstoreaccounts/bbstoreaccounts.cpp
r2695 r2709 209 209 } 210 210 211 int SetAccountName(Configuration &rConfig, const std::string &rUsername, 212 int32_t ID, const std::string& rNewAccountName) 213 { 214 // Become the user specified in the config file? 215 std::auto_ptr<UnixUser> user; 216 if(!rUsername.empty()) 217 { 218 // Username specified, change... 219 user.reset(new UnixUser(rUsername.c_str())); 220 user->ChangeProcessUser(true /* temporary */); 221 // Change will be undone at the end of this function 222 } 223 224 // Load in the account database 225 std::auto_ptr<BackupStoreAccountDatabase> db(BackupStoreAccountDatabase::Read(rConfig.GetKeyValue("AccountDatabase").c_str())); 226 227 // Already exists? 228 if(!db->EntryExists(ID)) 229 { 230 BOX_ERROR("Account " << BOX_FORMAT_ACCOUNT(ID) << 231 " does not exist."); 232 return 1; 233 } 234 235 // Load it in 236 BackupStoreAccounts acc(*db); 237 std::string rootDir; 238 int discSet; 239 acc.GetAccountRoot(ID, rootDir, discSet); 240 241 // Attempt to lock 242 NamedLock writeLock; 243 if(!GetWriteLockOnAccount(writeLock, rootDir, discSet)) 244 { 245 // Failed to get lock 246 return 1; 247 } 248 249 // Load the info 250 std::auto_ptr<BackupStoreInfo> info(BackupStoreInfo::Load(ID, 251 rootDir, discSet, false /* Read/Write */)); 252 253 info->SetAccountName(rNewAccountName); 254 255 // Save 256 info->Save(); 257 258 BOX_NOTICE("Account " << BOX_FORMAT_ACCOUNT(ID) << 259 " name changed to " << rNewAccountName); 260 261 return 0; 262 } 263 264 211 265 int AccountInfo(Configuration &rConfig, int32_t ID) 212 266 { … … 235 289 std::cout << FormatUsageLineStart("Account ID", sMachineReadableOutput) << 236 290 BOX_FORMAT_ACCOUNT(ID) << std::endl; 291 std::cout << FormatUsageLineStart("Account Name", sMachineReadableOutput) << 292 info->GetAccountName() << std::endl; 237 293 std::cout << FormatUsageLineStart("Last object ID", sMachineReadableOutput) << 238 294 BOX_FORMAT_OBJECTID(info->GetLastObjectIDUsed()) << std::endl; 239 295 std::cout << FormatUsageLineStart("Used", sMachineReadableOutput) << 240 296 BlockSizeToString(info->GetBlocksUsed(), 297 info->GetBlocksHardLimit(), discSet) << std::endl; 298 std::cout << FormatUsageLineStart("Current files", 299 sMachineReadableOutput) << 300 BlockSizeToString(info->GetBlocksInCurrentFiles(), 241 301 info->GetBlocksHardLimit(), discSet) << std::endl; 242 302 std::cout << FormatUsageLineStart("Old files", sMachineReadableOutput) << … … 257 317 std::cout << FormatUsageLineStart("Client store marker", sMachineReadableOutput) << 258 318 info->GetLastObjectIDUsed() << std::endl; 319 std::cout << FormatUsageLineStart("Live Files", sMachineReadableOutput) << 320 info->GetNumFiles() << std::endl; 321 std::cout << FormatUsageLineStart("Old Files", sMachineReadableOutput) << 322 info->GetNumOldFiles() << std::endl; 323 std::cout << FormatUsageLineStart("Deleted Files", sMachineReadableOutput) << 324 info->GetNumDeletedFiles() << std::endl; 325 std::cout << FormatUsageLineStart("Directories", sMachineReadableOutput) << 326 info->GetNumDirectories() << std::endl; 259 327 260 328 return 0; … … 452 520 " will be fixed. If the 'quiet' option is provided, less output is\n" 453 521 " produced.\n" 522 " name <account> <new name>\n" 523 " Changes the \"name\" of the account to the specified string.\n" 524 " The name is purely cosmetic and intended to make it easier to\n" 525 " identify your accounts.\n" 454 526 ); 455 527 exit(2); … … 570 642 571 643 return SetLimit(*config, username, id, argv[2], argv[3]); 644 } 645 else if(::strcmp(argv[0], "name") == 0) 646 { 647 // Change the limits on this account 648 if(argc != 3) 649 { 650 BOX_ERROR("name command requires a new name."); 651 return 1; 652 } 653 654 return SetAccountName(*config, username, id, argv[2]); 572 655 } 573 656 else if(::strcmp(argv[0], "delete") == 0)
Note: See TracChangeset
for help on using the changeset viewer.
