Browse Source

models: rename RewriteAllPublicKeys -> RewriteAuthorizedKeys

Unknwon 6 years ago
parent
commit
a855abf8c0
4 changed files with 11 additions and 9 deletions
  1. 4 4
      cmd/admin.go
  2. 5 3
      models/ssh_key.go
  3. 1 1
      models/user.go
  4. 1 1
      routes/admin/admin.go

+ 4 - 4
cmd/admin.go

@@ -27,7 +27,7 @@ to make automatic initialization process more smoothly`,
 			subcmdDeleteRepositoryArchives,
 			subcmdDeleteMissingRepositories,
 			subcmdGitGcRepos,
-			subcmdRewriteAllPublicKeys,
+			subcmdRewriteAuthorizedKeys,
 			subcmdSyncRepositoryHooks,
 			subcmdReinitMissingRepositories,
 		},
@@ -94,11 +94,11 @@ to make automatic initialization process more smoothly`,
 		},
 	}
 
-	subcmdRewriteAllPublicKeys = cli.Command{
-		Name:  "rewrite-public-keys",
+	subcmdRewriteAuthorizedKeys = cli.Command{
+		Name:  "rewrite-authorized-keys",
 		Usage: "Rewrite '.ssh/authorized_keys' file (caution: non-Gogs keys will be lost)",
 		Action: adminDashboardOperation(
-			models.RewriteAllPublicKeys,
+			models.RewriteAuthorizedKeys,
 			"All public keys have been rewritten successfully",
 		),
 		Flags: []cli.Flag{

+ 5 - 3
models/ssh_key.go

@@ -512,16 +512,18 @@ func DeletePublicKey(doer *User, id int64) (err error) {
 		return err
 	}
 
-	return RewriteAllPublicKeys()
+	return RewriteAuthorizedKeys()
 }
 
-// RewriteAllPublicKeys removes any authorized key and rewrite all keys from database again.
+// RewriteAuthorizedKeys removes any authorized key and rewrite all keys from database again.
 // Note: x.Iterate does not get latest data after insert/delete, so we have to call this function
 // outsite any session scope independently.
-func RewriteAllPublicKeys() error {
+func RewriteAuthorizedKeys() error {
 	sshOpLocker.Lock()
 	defer sshOpLocker.Unlock()
 
+	log.Trace("Doing: RewriteAuthorizedKeys")
+
 	os.MkdirAll(setting.SSH.RootPath, os.ModePerm)
 	fpath := filepath.Join(setting.SSH.RootPath, "authorized_keys")
 	tmpPath := fpath + ".tmp"

+ 1 - 1
models/user.go

@@ -853,7 +853,7 @@ func DeleteUser(u *User) (err error) {
 		return err
 	}
 
-	return RewriteAllPublicKeys()
+	return RewriteAuthorizedKeys()
 }
 
 // DeleteInactivateUsers deletes all inactivate users and email addresses.

+ 1 - 1
routes/admin/admin.go

@@ -151,7 +151,7 @@ func Dashboard(c *context.Context) {
 			err = models.GitGcRepos()
 		case SYNC_SSH_AUTHORIZED_KEY:
 			success = c.Tr("admin.dashboard.resync_all_sshkeys_success")
-			err = models.RewriteAllPublicKeys()
+			err = models.RewriteAuthorizedKeys()
 		case SYNC_REPOSITORY_HOOKS:
 			success = c.Tr("admin.dashboard.resync_all_hooks_success")
 			err = models.SyncRepositoryHooks()