mirror of
https://github.com/lordmathis/lemma.git
synced 2025-11-06 07:54:22 +00:00
Add logging to storage package
This commit is contained in:
@@ -17,6 +17,12 @@ type WorkspaceManager interface {
|
||||
// ValidatePath validates the if the given path is valid within the workspace directory.
|
||||
// Workspace directory is defined as the directory for the given userID and workspaceID.
|
||||
func (s *Service) ValidatePath(userID, workspaceID int, path string) (string, error) {
|
||||
log := getLogger()
|
||||
log.Debug("validating path",
|
||||
"userID", userID,
|
||||
"workspaceID", workspaceID,
|
||||
"path", path)
|
||||
|
||||
workspacePath := s.GetWorkspacePath(userID, workspaceID)
|
||||
|
||||
// First check if the path is absolute
|
||||
@@ -43,6 +49,11 @@ func (s *Service) GetWorkspacePath(userID, workspaceID int) string {
|
||||
|
||||
// InitializeUserWorkspace creates the workspace directory for the given userID and workspaceID.
|
||||
func (s *Service) InitializeUserWorkspace(userID, workspaceID int) error {
|
||||
log := getLogger()
|
||||
log.Debug("initializing workspace directory",
|
||||
"userID", userID,
|
||||
"workspaceID", workspaceID)
|
||||
|
||||
workspacePath := s.GetWorkspacePath(userID, workspaceID)
|
||||
err := s.fs.MkdirAll(workspacePath, 0755)
|
||||
if err != nil {
|
||||
@@ -54,6 +65,11 @@ func (s *Service) InitializeUserWorkspace(userID, workspaceID int) error {
|
||||
|
||||
// DeleteUserWorkspace deletes the workspace directory for the given userID and workspaceID.
|
||||
func (s *Service) DeleteUserWorkspace(userID, workspaceID int) error {
|
||||
log := getLogger()
|
||||
log.Debug("deleting workspace directory",
|
||||
"userID", userID,
|
||||
"workspaceID", workspaceID)
|
||||
|
||||
workspacePath := s.GetWorkspacePath(userID, workspaceID)
|
||||
err := s.fs.RemoveAll(workspacePath)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user