Remove too many debug messages

This commit is contained in:
2024-12-19 22:00:42 +01:00
parent 0aa67f5cc2
commit b065938211
26 changed files with 75 additions and 586 deletions

View File

@@ -30,21 +30,12 @@ type FileNode struct {
// ListFilesRecursively returns a list of all files in the workspace directory and its subdirectories.
// Workspace is identified by the given userID and workspaceID.
func (s *Service) ListFilesRecursively(userID, workspaceID int) ([]FileNode, error) {
log := getLogger()
log.Debug("listing files recursively",
"userID", userID,
"workspaceID", workspaceID)
workspacePath := s.GetWorkspacePath(userID, workspaceID)
nodes, err := s.walkDirectory(workspacePath, "")
if err != nil {
return nil, err
}
log.Debug("file listing complete",
"userID", userID,
"workspaceID", workspaceID,
"nodeCount", len(nodes))
return nodes, nil
}
@@ -116,12 +107,6 @@ func (s *Service) walkDirectory(dir, prefix string) ([]FileNode, error) {
// Files are searched recursively in the workspace directory and its subdirectories.
// Workspace is identified by the given userID and workspaceID.
func (s *Service) FindFileByName(userID, workspaceID int, filename string) ([]string, error) {
log := getLogger()
log.Debug("searching for file by name",
"userID", userID,
"workspaceID", workspaceID,
"filename", filename)
var foundPaths []string
workspacePath := s.GetWorkspacePath(userID, workspaceID)
@@ -149,23 +134,12 @@ func (s *Service) FindFileByName(userID, workspaceID int, filename string) ([]st
return nil, fmt.Errorf("file not found")
}
log.Debug("file search complete",
"userID", userID,
"workspaceID", workspaceID,
"filename", filename,
"matchCount", len(foundPaths))
return foundPaths, nil
}
// GetFileContent returns the content of the file at the given filePath.
// Path must be a relative path within the workspace directory given by userID and workspaceID.
func (s *Service) GetFileContent(userID, workspaceID int, filePath string) ([]byte, error) {
log := getLogger()
log.Debug("reading file content",
"userID", userID,
"workspaceID", workspaceID,
"path", filePath)
fullPath, err := s.ValidatePath(userID, workspaceID, filePath)
if err != nil {
return nil, err
@@ -177,11 +151,6 @@ func (s *Service) GetFileContent(userID, workspaceID int, filePath string) ([]by
// Path must be a relative path within the workspace directory given by userID and workspaceID.
func (s *Service) SaveFile(userID, workspaceID int, filePath string, content []byte) error {
log := getLogger()
log.Debug("saving file",
"userID", userID,
"workspaceID", workspaceID,
"path", filePath,
"contentSize", len(content))
fullPath, err := s.ValidatePath(userID, workspaceID, filePath)
if err != nil {
@@ -209,11 +178,6 @@ func (s *Service) SaveFile(userID, workspaceID int, filePath string, content []b
// Path must be a relative path within the workspace directory given by userID and workspaceID.
func (s *Service) DeleteFile(userID, workspaceID int, filePath string) error {
log := getLogger()
log.Debug("deleting file",
"userID", userID,
"workspaceID", workspaceID,
"path", filePath)
fullPath, err := s.ValidatePath(userID, workspaceID, filePath)
if err != nil {
return err
@@ -239,11 +203,6 @@ type FileCountStats struct {
// GetFileStats returns the total number of files and related statistics in a workspace
// Workspace is identified by the given userID and workspaceID
func (s *Service) GetFileStats(userID, workspaceID int) (*FileCountStats, error) {
log := getLogger()
log.Debug("gathering file statistics",
"userID", userID,
"workspaceID", workspaceID)
workspacePath := s.GetWorkspacePath(userID, workspaceID)
// Check if workspace exists
@@ -256,27 +215,16 @@ func (s *Service) GetFileStats(userID, workspaceID int) (*FileCountStats, error)
return nil, err
}
log.Debug("file statistics collected",
"userID", userID,
"workspaceID", workspaceID,
"totalFiles", stats.TotalFiles,
"totalSize", stats.TotalSize)
return stats, nil
}
// GetTotalFileStats returns the total file statistics for the storage.
func (s *Service) GetTotalFileStats() (*FileCountStats, error) {
log := getLogger()
log.Debug("gathering total storage statistics")
stats, err := s.countFilesInPath(s.RootDir)
if err != nil {
return nil, err
}
log.Debug("total storage statistics collected",
"totalFiles", stats.TotalFiles,
"totalSize", stats.TotalSize)
return stats, nil
}

View File

@@ -16,17 +16,9 @@ type RepositoryManager interface {
// SetupGitRepo sets up a Git repository for the given userID and workspaceID.
// The repository is cloned from the given gitURL using the given gitUser and gitToken.
func (s *Service) SetupGitRepo(userID, workspaceID int, gitURL, gitUser, gitToken, commitName, commitEmail string) error {
log := getLogger()
log.Info("setting up git repository",
"userID", userID,
"workspaceID", workspaceID,
)
workspacePath := s.GetWorkspacePath(userID, workspaceID)
if _, ok := s.GitRepos[userID]; !ok {
log.Debug("initializing git repo map for user",
"userID", userID)
s.GitRepos[userID] = make(map[int]git.Client)
}
@@ -37,16 +29,14 @@ func (s *Service) SetupGitRepo(userID, workspaceID int, gitURL, gitUser, gitToke
// DisableGitRepo disables the Git repository for the given userID and workspaceID.
func (s *Service) DisableGitRepo(userID, workspaceID int) {
log := getLogger()
log.Info("disabling git repository",
log := getLogger().WithGroup("git")
log.Debug("disabling git repository",
"userID", userID,
"workspaceID", workspaceID)
if userRepos, ok := s.GitRepos[userID]; ok {
delete(userRepos, workspaceID)
if len(userRepos) == 0 {
log.Debug("removing empty user git repos map",
"userID", userID)
delete(s.GitRepos, userID)
}
}
@@ -55,12 +45,6 @@ func (s *Service) DisableGitRepo(userID, workspaceID int) {
// StageCommitAndPush stages, commit with the message, and pushes the changes to the Git repository.
// The git repository belongs to the given userID and is associated with the given workspaceID.
func (s *Service) StageCommitAndPush(userID, workspaceID int, message string) (git.CommitHash, error) {
log := getLogger()
log.Debug("preparing to stage, commit and push changes",
"userID", userID,
"workspaceID", workspaceID,
"message", message)
repo, ok := s.getGitRepo(userID, workspaceID)
if !ok {
return git.CommitHash{}, fmt.Errorf("git settings not configured for this workspace")
@@ -75,21 +59,12 @@ func (s *Service) StageCommitAndPush(userID, workspaceID int, message string) (g
return hash, err
}
log.Debug("changes committed and pushed",
"userID", userID,
"workspaceID", workspaceID,
"commitHash", hash.String())
return hash, nil
}
// Pull pulls the changes from the remote Git repository.
// The git repository belongs to the given userID and is associated with the given workspaceID.
func (s *Service) Pull(userID, workspaceID int) error {
log := getLogger()
log.Debug("preparing to pull changes",
"userID", userID,
"workspaceID", workspaceID)
repo, ok := s.getGitRepo(userID, workspaceID)
if !ok {
return fmt.Errorf("git settings not configured for this workspace")
@@ -100,9 +75,6 @@ func (s *Service) Pull(userID, workspaceID int) error {
return err
}
log.Debug("changes pulled from remote",
"userID", userID,
"workspaceID", workspaceID)
return nil
}

View File

@@ -43,18 +43,13 @@ func NewServiceWithOptions(rootDir string, options Options) *Service {
"rootDir", rootDir)
if options.Fs == nil {
log.Debug("filesystem not provided, using default osFS")
options.Fs = &osFS{}
}
if options.NewGitClient == nil {
log.Debug("git client factory not provided, using default git.New")
options.NewGitClient = git.New
}
log.Info("storage service created",
"rootDir", rootDir)
return &Service{
fs: options.Fs,
newGitClient: options.NewGitClient,

View File

@@ -17,12 +17,6 @@ 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