attempting to fix the symlink issue being the wrong direction, fixing the log folder not existing error

This commit is contained in:
2018-01-19 21:49:19 -05:00
parent c4b86bcf1d
commit aa9082f598
5 changed files with 34 additions and 13 deletions

View File

@@ -0,0 +1,13 @@
[Unit]
Description=goTorrent Server
After=network.target
[Service]
type=simple
User=goTorrent
WorkingDirectory=/opt/goTorrent
ExecStart=/opt/goTorrent/goTorrent
Restart=on-abort
[Install]
WantedBy=multi-user.target

View File

@@ -67,7 +67,9 @@ func MoveAndLeaveSymlink(config FullClientSettings, singleTorrent *torrent.Torre
Logger.WithFields(logrus.Fields{"Old File Path": oldFilePath, "New File Path": newFilePath, "bytesWritten": bytesWritten}).Info("Windows Torrent Copy Completed") Logger.WithFields(logrus.Fields{"Old File Path": oldFilePath, "New File Path": newFilePath, "bytesWritten": bytesWritten}).Info("Windows Torrent Copy Completed")
notifyUser(tStorage, config, singleTorrent, db) notifyUser(tStorage, config, singleTorrent, db)
} else { } else {
err := os.Symlink(oldFilePath, newFilePath) //For all other OS's create a symlink folderCopy.Copy(oldFilePath, newFilePath)
os.RemoveAll(oldFilePath)
err := os.Symlink(newFilePath, oldFilePath) //For all other OS's create a symlink
if err != nil { if err != nil {
Logger.WithFields(logrus.Fields{"Old File Path": oldFilePath, "New File Path": newFilePath, "error": err}).Error("Error creating symlink") Logger.WithFields(logrus.Fields{"Old File Path": oldFilePath, "New File Path": newFilePath, "error": err}).Error("Error creating symlink")
return return

View File

@@ -57,9 +57,7 @@ export default class addTorrentFilePopup extends React.Component {
}; };
handleSubmit = () => { handleSubmit = () => {
this.setState({ open: false }); this.setState({open: false})
//let magnetLinkSubmit = this.state.textValue;
console.log("File", this.state.torrentFileValue)
const reader = new FileReader() const reader = new FileReader()
let torrentFileBlob = new Blob(this.state.torrentFileValue) let torrentFileBlob = new Blob(this.state.torrentFileValue)
console.log("Blob", torrentFileBlob) console.log("Blob", torrentFileBlob)
@@ -76,6 +74,7 @@ export default class addTorrentFilePopup extends React.Component {
} }
console.log("Sending magnet link: ", torrentFileMessage); console.log("Sending magnet link: ", torrentFileMessage);
ws.send(JSON.stringify(torrentFileMessage)); ws.send(JSON.stringify(torrentFileMessage));
this.setState({torrentFileName: "", storageValue: "", torrentFileValue: [], showDrop: true})
} }
} }

10
main.go
View File

@@ -60,6 +60,13 @@ func main() {
Storage.Logger = Logger Storage.Logger = Logger
Config := Engine.FullClientSettingsNew() //grabbing from settings.go Config := Engine.FullClientSettingsNew() //grabbing from settings.go
if Config.LoggingOutput == "file" { if Config.LoggingOutput == "file" {
_, err := os.Stat("logs/server.log")
if os.IsNotExist(err) {
err := os.Mkdir("logs", 0644)
if err != nil {
fmt.Println("Unable to create 'log' folder for logging.... please check permissions.. forcing output to stdout")
}
} else {
os.Remove("logs/server.log") //cleanup the old log on every restart os.Remove("logs/server.log") //cleanup the old log on every restart
file, err := os.OpenFile("logs/server.log", os.O_CREATE|os.O_WRONLY, 0666) //creating the log file file, err := os.OpenFile("logs/server.log", os.O_CREATE|os.O_WRONLY, 0666) //creating the log file
defer file.Close() //TODO.. since we write to this constantly how does close work? defer file.Close() //TODO.. since we write to this constantly how does close work?
@@ -67,7 +74,8 @@ func main() {
fmt.Println("Unable to create file for logging.... please check permissions.. forcing output to stdout") fmt.Println("Unable to create file for logging.... please check permissions.. forcing output to stdout")
Logger.Out = os.Stdout Logger.Out = os.Stdout
} }
Logger.Out = file //Setting our logger to output to the file Logger.Out = file
}
} else { } else {
Logger.Out = os.Stdout Logger.Out = os.Stdout
} }

View File

@@ -93510,8 +93510,6 @@ var addTorrentFilePopup = function (_React$Component) {
_this.setState({ open: false }); _this.setState({ open: false });
}, _this.handleSubmit = function () { }, _this.handleSubmit = function () {
_this.setState({ open: false }); _this.setState({ open: false });
//let magnetLinkSubmit = this.state.textValue;
console.log("File", _this.state.torrentFileValue);
var reader = new FileReader(); var reader = new FileReader();
var torrentFileBlob = new Blob(_this.state.torrentFileValue); var torrentFileBlob = new Blob(_this.state.torrentFileValue);
console.log("Blob", torrentFileBlob); console.log("Blob", torrentFileBlob);
@@ -93528,6 +93526,7 @@ var addTorrentFilePopup = function (_React$Component) {
}; };
console.log("Sending magnet link: ", torrentFileMessage); console.log("Sending magnet link: ", torrentFileMessage);
ws.send(JSON.stringify(torrentFileMessage)); ws.send(JSON.stringify(torrentFileMessage));
_this.setState({ torrentFileName: "", storageValue: "", torrentFileValue: [], showDrop: true });
}; };
}, _this.onFileLoad = function (file) { }, _this.onFileLoad = function (file) {
_this.setState({ torrentFileName: file[0].name }); _this.setState({ torrentFileName: file[0].name });