Add disk usage. need to fix change_directory function

This commit is contained in:
kyg516
2016-09-25 01:24:28 +09:00
parent dd2f52a7d1
commit b10c6803ac
7 changed files with 139 additions and 95 deletions

View File

@@ -2,6 +2,7 @@ class ApplicationController < ActionController::Base
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
# protect_from_forgery with: :exception
include ApplicationHelper
def require_login
unless user_signed_in?
@@ -32,29 +33,8 @@ class ApplicationController < ActionController::Base
return df
end
def file_directory(dir)
@current_dir = dir
dir_list = `ls #{@current_dir} -l`
parsing_list = dir_list.split("\n")
@files = Array.new
file = Hash.new
@total_list = parsing_list[0]
for t in 1..(parsing_list.length-1)
parsing_file = parsing_list[t].split(" ")
file["auth"] = parsing_file[0]
file["size"] = parsing_file[4]
file["date"] = parsing_file[5] + " " + parsing_file[6] + " " + parsing_file[7]
file["name"] = parsing_file[8]
@files << file
file = Hash.new
end
puts @files
return @files
end
def checkDir
files = file_directory(params[:path])
render :json => {:file => files , :current => @current_dir}
@current_dir = params[:path]
render :json => {:file => files(@current_dir) , :current => @current_dir}
end
end

View File

@@ -3,7 +3,6 @@ class HomeController < ApplicationController
def index
@current_dir = "/mnt"
file_directory(@current_dir)
end
def file_download

View File

@@ -2,7 +2,7 @@ class VolumeController < ApplicationController
before_action :require_login
def index
file_directory("/mnt")
@current_dir = "/mnt"
end
def file_upload