浏览代码

Updated versio to 2.007

Toby Chui 2 年之前
父节点
当前提交
1073036035
共有 6 个文件被更改,包括 90 次插入92 次删除
  1. 1 1
      main.flags.go
  2. 3 4
      mod/user/directoryHandler.go
  3. 52 52
      mod/user/internal.go
  4. 3 3
      mod/user/permissionHandler.go
  5. 1 1
      mod/user/user.go
  6. 30 31
      mod/user/useropr.go

+ 1 - 1
main.flags.go

@@ -29,7 +29,7 @@ var subserviceBasePort = 12810            //Next subservice port
 
 // =========== SYSTEM BUILD INFORMATION ==============
 var build_version = "development"                      //System build flag, this can be either {development / production / stable}
-var internal_version = "0.2.006"                       //Internal build version, [fork_id].[major_release_no].[minor_release_no]
+var internal_version = "0.2.007"                       //Internal build version, [fork_id].[major_release_no].[minor_release_no]
 var deviceUUID string                                  //The device uuid of this host
 var deviceVendor = "IMUSLAB.INC"                       //Vendor of the system
 var deviceVendorURL = "http://imuslab.com"             //Vendor contact information

+ 3 - 4
mod/user/directoryHandler.go

@@ -5,7 +5,6 @@ import (
 	"os"
 	"path/filepath"
 
-	"imuslab.com/arozos/mod/filesystem"
 	fs "imuslab.com/arozos/mod/filesystem"
 	"imuslab.com/arozos/mod/utils"
 )
@@ -40,7 +39,7 @@ func (u *User) GetAllAccessibleFileSystemHandler() []*fs.FileSystemHandler {
 //Try to get the root file system handler from vpath where the root file system handler must be in user scope of permission
 func (u *User) GetRootFSHFromVpathInUserScope(vpath string) *fs.FileSystemHandler {
 	allFsh := u.GetAllAccessibleFileSystemHandler()
-	var vpathSourceFsh *filesystem.FileSystemHandler
+	var vpathSourceFsh *fs.FileSystemHandler
 	for _, thisFsh := range allFsh {
 		if thisFsh.IsRootOf(vpath) {
 			vpathSourceFsh = thisFsh
@@ -55,7 +54,7 @@ func (u *User) GetAllFileSystemHandler() []*fs.FileSystemHandler {
 	uuids := []string{}
 	//Get all FileSystem Handler from this user's Home Directory (aka base directory)
 	for _, store := range u.HomeDirectories.Storages {
-		if store.Closed == false {
+		if !store.Closed {
 			//Only return opened file system handlers
 			results = append(results, store)
 			uuids = append(uuids, store.UUID)
@@ -69,7 +68,7 @@ func (u *User) GetAllFileSystemHandler() []*fs.FileSystemHandler {
 		for _, store := range pg.StoragePool.Storages {
 			//Get each of the storage of this permission group is assigned to
 			if !utils.StringInArray(uuids, store.UUID) {
-				if store.Closed == false {
+				if !store.Closed {
 					//Only return opened file system handlers
 					results = append(results, store)
 					uuids = append(uuids, store.UUID)

+ 52 - 52
mod/user/internal.go

@@ -1,52 +1,52 @@
-package user
-
-import (
-	"errors"
-	"path/filepath"
-	"strings"
-
-	fs "imuslab.com/arozos/mod/filesystem"
-)
-
-/*
-	Private functions
-*/
-
-//Get a fs handler from a virtual path, quick function for getIDFromHandler + GetHandlerFromID
-func getHandlerFromVirtualPath(storages []*fs.FileSystemHandler, vpath string) (*fs.FileSystemHandler, error) {
-	vid, _, err := getIDFromVirtualPath(vpath)
-	if err != nil {
-		return &fs.FileSystemHandler{}, err
-	}
-
-	return getHandlerFromID(storages, vid)
-}
-
-//Get a fs handler from the given virtial device id
-func getHandlerFromID(storages []*fs.FileSystemHandler, vid string) (*fs.FileSystemHandler, error) {
-	for _, storage := range storages {
-		if storage.UUID == vid {
-			//This storage is the one we are looking at
-			return storage, nil
-		}
-	}
-
-	return &fs.FileSystemHandler{}, errors.New("Handler Not Found")
-}
-
-//Get the ID part of a virtual path, return ID, subpath and error
-func getIDFromVirtualPath(vpath string) (string, string, error) {
-	if strings.Contains(vpath, ":") == false {
-		return "", "", errors.New("Path missing Virtual Device ID. Given: " + vpath)
-	}
-
-	//Clean up the virutal path
-	vpath = filepath.ToSlash(filepath.Clean(vpath))
-
-	tmp := strings.Split(vpath, ":")
-	vdID := tmp[0]
-	pathSlice := tmp[1:]
-	path := strings.Join(pathSlice, ":")
-
-	return vdID, path, nil
-}
+package user
+
+import (
+	"errors"
+	"path/filepath"
+	"strings"
+
+	fs "imuslab.com/arozos/mod/filesystem"
+)
+
+/*
+	Private functions
+*/
+
+//Get a fs handler from a virtual path, quick function for getIDFromHandler + GetHandlerFromID
+func getHandlerFromVirtualPath(storages []*fs.FileSystemHandler, vpath string) (*fs.FileSystemHandler, error) {
+	vid, _, err := getIDFromVirtualPath(vpath)
+	if err != nil {
+		return &fs.FileSystemHandler{}, err
+	}
+
+	return getHandlerFromID(storages, vid)
+}
+
+//Get a fs handler from the given virtial device id
+func getHandlerFromID(storages []*fs.FileSystemHandler, vid string) (*fs.FileSystemHandler, error) {
+	for _, storage := range storages {
+		if storage.UUID == vid {
+			//This storage is the one we are looking at
+			return storage, nil
+		}
+	}
+
+	return &fs.FileSystemHandler{}, errors.New("handler Not Found")
+}
+
+//Get the ID part of a virtual path, return ID, subpath and error
+func getIDFromVirtualPath(vpath string) (string, string, error) {
+	if !strings.Contains(vpath, ":") {
+		return "", "", errors.New("path missing Virtual Device ID. Given: " + vpath)
+	}
+
+	//Clean up the virutal path
+	vpath = filepath.ToSlash(filepath.Clean(vpath))
+
+	tmp := strings.Split(vpath, ":")
+	vdID := tmp[0]
+	pathSlice := tmp[1:]
+	path := strings.Join(pathSlice, ":")
+
+	return vdID, path, nil
+}

+ 3 - 3
mod/user/permissionHandler.go

@@ -17,7 +17,7 @@ func (u *User) GetModuleAccessPermission(moduleName string) bool {
 	//Check if this module permission is within user's permission group access
 	moduleName = strings.ToLower(moduleName)
 	for _, pg := range u.PermissionGroup {
-		if pg.IsAdmin == true {
+		if pg.IsAdmin {
 			//This user is admin. Allow all module access
 			return true
 		} else if utils.StringInArrayIgnoreCase(pg.AccessibleModules, moduleName) {
@@ -65,7 +65,7 @@ func (u *User) GetUserAccessibleModules() []string {
 func (u *User) IsAdmin() bool {
 	isAdmin := false
 	for _, pg := range u.PermissionGroup {
-		if pg.IsAdmin == true {
+		if pg.IsAdmin {
 			isAdmin = true
 		}
 	}
@@ -168,7 +168,7 @@ func (u *User) GetHighestAccessRightStoragePool(fsUUID string) (*storage.Storage
 
 	//Check the highest priority in the list
 	if len(matchingStoragePool) == 0 {
-		return &storage.StoragePool{}, errors.New("No access to this filesystem was found")
+		return &storage.StoragePool{}, errors.New("no access to this filesystem was found")
 	}
 
 	currentTopStoragePool := matchingStoragePool[0]

+ 1 - 1
mod/user/user.go

@@ -165,7 +165,7 @@ func (u *UserHandler) GetUsersInPermissionGroup(permissionGroupName string) ([]*
 	//Check if the given group exists
 	if u.phandler.GetPermissionGroupByName(permissionGroupName) == nil {
 		//Permission group with given name not exists
-		return results, errors.New("Permission group not exists")
+		return results, errors.New("permission group not exists")
 	}
 
 	AllRegisteredUsers := u.authAgent.ListUsers()

+ 30 - 31
mod/user/useropr.go

@@ -1,31 +1,30 @@
-package user
-
-import "log"
-
-//Get the user's handler
-func (u *User) Parent() *UserHandler {
-	return u.parent
-}
-
-//Remove the current user
-func (u *User) RemoveUser() {
-	//Remove the user storage quota settings
-	log.Println("Removing User Quota: ", u.Username)
-	u.StorageQuota.RemoveUserQuota()
-
-	//Remove the user authentication register
-	u.parent.authAgent.UnregisterUser(u.Username)
-}
-
-//Get the current user icon
-func (u *User) GetUserIcon() string {
-	var userIconpath []byte
-	u.parent.database.Read("auth", "profilepic/"+u.Username, &userIconpath)
-	return string(userIconpath)
-}
-
-//Set the current user icon
-func (u *User) SetUserIcon(base64data string) {
-	u.parent.database.Write("auth", "profilepic/"+u.Username, []byte(base64data))
-	return
-}
+package user
+
+import "log"
+
+//Get the user's handler
+func (u *User) Parent() *UserHandler {
+	return u.parent
+}
+
+//Remove the current user
+func (u *User) RemoveUser() {
+	//Remove the user storage quota settings
+	log.Println("Removing User Quota: ", u.Username)
+	u.StorageQuota.RemoveUserQuota()
+
+	//Remove the user authentication register
+	u.parent.authAgent.UnregisterUser(u.Username)
+}
+
+//Get the current user icon
+func (u *User) GetUserIcon() string {
+	var userIconpath []byte
+	u.parent.database.Read("auth", "profilepic/"+u.Username, &userIconpath)
+	return string(userIconpath)
+}
+
+//Set the current user icon
+func (u *User) SetUserIcon(base64data string) {
+	u.parent.database.Write("auth", "profilepic/"+u.Username, []byte(base64data))
+}