mirror of
				https://github.com/minio/minio.git
				synced 2025-11-04 02:01:05 +01:00 
			
		
		
		
	Merge pull request #123 from harshavardhana/pr_out_use_helper_homedir_
This commit is contained in:
		
						commit
						c26b6f3d76
					
				@ -19,7 +19,6 @@ package server
 | 
				
			|||||||
import (
 | 
					import (
 | 
				
			||||||
	"log"
 | 
						"log"
 | 
				
			||||||
	"os"
 | 
						"os"
 | 
				
			||||||
	"os/user"
 | 
					 | 
				
			||||||
	"path"
 | 
						"path"
 | 
				
			||||||
	"reflect"
 | 
						"reflect"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -29,6 +28,7 @@ import (
 | 
				
			|||||||
	mstorage "github.com/minio-io/minio/pkg/storage"
 | 
						mstorage "github.com/minio-io/minio/pkg/storage"
 | 
				
			||||||
	"github.com/minio-io/minio/pkg/storage/fs"
 | 
						"github.com/minio-io/minio/pkg/storage/fs"
 | 
				
			||||||
	"github.com/minio-io/minio/pkg/storage/inmemory"
 | 
						"github.com/minio-io/minio/pkg/storage/inmemory"
 | 
				
			||||||
 | 
						"github.com/minio-io/minio/pkg/utils/helpers"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type ServerConfig struct {
 | 
					type ServerConfig struct {
 | 
				
			||||||
@ -128,13 +128,9 @@ func getStorageChannels(storageType StorageType) (ctrlChans []chan<- string, sta
 | 
				
			|||||||
		}
 | 
							}
 | 
				
			||||||
	case storageType == FileStorage:
 | 
						case storageType == FileStorage:
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			// TODO Replace this with a more configurable and robust version
 | 
								homeDir := helpers.HomeDir()
 | 
				
			||||||
			currentUser, err := user.Current()
 | 
								rootPath := path.Join(homeDir, "minio-storage")
 | 
				
			||||||
			if err != nil {
 | 
								_, err := os.Stat(rootPath)
 | 
				
			||||||
				log.Fatal(err)
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
			rootPath := path.Join(currentUser.HomeDir, "minio-storage")
 | 
					 | 
				
			||||||
			_, err = os.Stat(rootPath)
 | 
					 | 
				
			||||||
			if os.IsNotExist(err) {
 | 
								if os.IsNotExist(err) {
 | 
				
			||||||
				err = os.Mkdir(rootPath, 0700)
 | 
									err = os.Mkdir(rootPath, 0700)
 | 
				
			||||||
			} else if err != nil {
 | 
								} else if err != nil {
 | 
				
			||||||
 | 
				
			|||||||
@ -14,14 +14,27 @@
 | 
				
			|||||||
 * limitations under the License.
 | 
					 * limitations under the License.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
package utils
 | 
					package helpers
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import (
 | 
					import (
 | 
				
			||||||
	"io/ioutil"
 | 
						"io/ioutil"
 | 
				
			||||||
	"log"
 | 
						"log"
 | 
				
			||||||
 | 
						"os"
 | 
				
			||||||
 | 
						"runtime"
 | 
				
			||||||
	"strings"
 | 
						"strings"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func HomeDir() string {
 | 
				
			||||||
 | 
						if runtime.GOOS == "windows" {
 | 
				
			||||||
 | 
							home := os.Getenv("HOMEDRIVE") + os.Getenv("HOMEPATH")
 | 
				
			||||||
 | 
							if home == "" {
 | 
				
			||||||
 | 
								home = os.Getenv("USERPROFILE")
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							return home
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						return os.Getenv("HOME")
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func MakeTempTestDir() (string, error) {
 | 
					func MakeTempTestDir() (string, error) {
 | 
				
			||||||
	return ioutil.TempDir("/tmp", "minio-test-")
 | 
						return ioutil.TempDir("/tmp", "minio-test-")
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@ -14,7 +14,7 @@
 | 
				
			|||||||
 * limitations under the License.
 | 
					 * limitations under the License.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
package utils
 | 
					package helpers
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import (
 | 
					import (
 | 
				
			||||||
	"bytes"
 | 
						"bytes"
 | 
				
			||||||
@ -14,7 +14,7 @@
 | 
				
			|||||||
 * limitations under the License.
 | 
					 * limitations under the License.
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
package utils
 | 
					package helpers
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import (
 | 
					import (
 | 
				
			||||||
	"io/ioutil"
 | 
						"io/ioutil"
 | 
				
			||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user