Skip to content

Commit

Permalink
file_selector.js: revert PR by @aurismus
Browse files Browse the repository at this point in the history
Lots of bugs since I merged PR by aurismus. 
Bugs with watch button: #114
  • Loading branch information
YIFYtorrents authored Dec 23, 2016
1 parent 66f2a2e commit 0d574f3
Showing 1 changed file with 25 additions and 25 deletions.
50 changes: 25 additions & 25 deletions src/app/lib/views/file_selector.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@
} else if (!Settings.droppedStoredMagnet) {
//else if (Settings.droppedMagnet && !Settings.droppedStoredMagnet) {
_file = Settings.droppedMagnet,
file = formatMagnet(_file) + '.torrent';
file = formatMagnet(_file);
//alert("droppedMagnet, droppedStoredMagnet=false: "+file);
} else if (Settings.droppedStoredMagnet) {
//else if (Settings.droppedMagnet && Settings.droppedStoredMagnet) {
Expand All @@ -151,44 +151,44 @@
},

storeTorrent: function () {
var torrent_display_name, torrent_file_name, cached_torrent_hashname;

var source = require('os').tmpDir() + '/Popcorn-Time/TorrentCache/',
target = require('nw.gui').App.dataPath + '/TorrentCollection/';
var source = App.settings.tmpLocation + '/',
target = require('nw.gui').App.dataPath + '/TorrentCollection/',
file,
_file;

if (Settings.droppedTorrent) {
torrent_file_name = Settings.droppedTorrent;
cached_torrent_hashname = Common.md5(path.basename(torrent_file_name));
file = Settings.droppedTorrent;

if (this.isTorrentStored()) {
fs.unlinkSync(target + torrent_file_name); // remove the torrent
win.debug('Torrent Collection: deleted', torrent_file_name);
//alert('Torrent Collection: deleted', torrent_file_name);
fs.unlinkSync(target + file); // remove the torrent
win.debug('Torrent Collection: deleted', file);
//alert('Torrent Collection: deleted', file);
} else {
if (!fs.existsSync(target)) {
fs.mkdir(target); // create directory if needed
}
fs.writeFileSync(target + torrent_file_name, fs.readFileSync(source + cached_torrent_hashname + '.torrent')); // save torrent
win.debug('Torrent Collection: added', torrent_file_name);
//alert('Torrent Collection: added', torrent_file_name);
fs.writeFileSync(target + file, fs.readFileSync(source + file)); // save torrent
win.debug('Torrent Collection: added', file);
//alert('Torrent Collection: added', file);
}
} else if (Settings.droppedMagnet) {
torrent_display_name = formatMagnet(Settings.droppedMagnet);
torrent_file_name = Settings.droppedStoredMagnet ? Settings.droppedStoredMagnet : torrent_display_name;
cached_torrent_hashname = Common.md5(path.basename(Settings.droppedMagnet));

if (this.isTorrentStored()) { // this is only for compatability, since we don't have magnet links stored anymore
fs.unlinkSync(target + torrent_file_name); // remove the magnet
win.debug('Torrent Collection: deleted', torrent_file_name);
//alert('Torrent Collection: deleted', torrent_file_name);
_file = Settings.droppedMagnet,
file = formatMagnet(_file);

if (this.isTorrentStored()) {
if (Settings.droppedStoredMagnet) {
file = Settings.droppedStoredMagnet;
}
fs.unlinkSync(target + file); // remove the magnet
win.debug('Torrent Collection: deleted', file);
//alert('Torrent Collection: deleted', file);
} else {
if (!fs.existsSync(target)) {
fs.mkdir(target); // create directory if needed
}

fs.writeFileSync(target + torrent_file_name + '.torrent', fs.readFileSync(source + cached_torrent_hashname + '.torrent')); // save torrent
win.debug('Torrent Collection: added', torrent_file_name);
//alert('Torrent Collection: added', torrent_file_name);
fs.writeFileSync(target + file, _file); // save magnet link inside readable file
win.debug('Torrent Collection: added', file);
//alert('Torrent Collection: added', file);
}
}
this.isTorrentStored(); // trigger button change
Expand Down

0 comments on commit 0d574f3

Please sign in to comment.