Skip to content

Commit

Permalink
Initial Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
blaize9 committed Aug 29, 2017
0 parents commit 9656ef0
Show file tree
Hide file tree
Showing 12 changed files with 1,515 additions and 0 deletions.
51 changes: 51 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
### OSX ###
.DS_Store
.AppleDouble
.LSOverride
Icon

# Thumbnails
._*

# Files that might appear on external disk
.Spotlight-V100
.Trashes

### Windows ###
# Windows image file caches
Thumbs.db
ehthumbs.db

# Folder config file
Desktop.ini

# Recycle Bin used on file shares
$RECYCLE.BIN/

### Linux ###
.*
!.gitignore
*~

### JetBrains ###
.idea/*

### Go ###
# Binaries for programs and plugins
*.exe
*.dll
*.so
*.dylib

# Test binary, build with `go test -c`
*.test

# Output of the go coverage tool, specifically when used with LiteIDE
*.out

# Project-local glide cache, RE: https://github.com/Masterminds/glide/issues/736
.glide/

### PROJECT SPECIFIC ###
hashstorage.struct
downloads.config
13 changes: 13 additions & 0 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004

Copyright (C) 2004 Sam Hocevar <[email protected]>

Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.

DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION

0. You just DO WHAT THE FUCK YOU WANT TO.
38 changes: 38 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Vuze Tools

### Information
Vuze Tools provides ways of recovering damaged active files and finds missing torrent files for the Vuze Bittorrent Client.

##### Program Options

Please make sure Vuze is shutdown before running, While it will still work it might read invalid information from your files.
I recommend running "Fix Active files", copying the recovered files, Launch Vuze and then quit, then run whichever recovery you want to use.

1. Fix Active files - Fix damaged active files by looking for .dat._AZ and .dat.saving which are created and kept if vuze crashed while saving.
2. Simple Recovery - missing torrent files by filename from backups (Normal - Once a valid torrent is found it will move on)
3. Advanced Recovery - missing torrent files by hash from backups (Slow - Scans every torrent file in backup, however it is resumable upon completion)
4. Active Recovery - missing torrent files by extracting from its active file. (Fast and Accurate - Checks the given hash for an active file and generates a new torrent)

Recovered files are placed in the same directory that contains your Azerus directory and is named "Azureus-recover"
Then the contents of "Azerus-recover" should be moved into your Azerus directory except for "AdvancedHashStorage.glob" (A resumable hashstroage generated by Advanced Recovery)

### Configuration
You may override the default_config.yml by creating a config/config.yml file inside the current directory.
you can also use the command line arguments
* '-env="type" [DEV,PROD,PROD-STDOUT,PROD-JSON]'
* '-azdir="/path/to/azureus/directory"' to set the location of your vuze configuration
* '-azconfig="/path/to/azureus/downloads.config"' to override the default azdir/downloads.config path
* '-azbackups="/path/to/backupfolder1,/path/to/backupfolder2"'

Note: Windows users will have to escape their filepath separator '\' to '\\'

### TODO

- [ ] Add Testing
- [ ] Add inline documentation

### LICENSE
This project is licensed under the WTFPL, Please see LICENSE.txt for more details.

### Disclaimer
While the tool is safe to use and will not modify any non-tool related files USE THIS AT YOUR OWN RISK.
122 changes: 122 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
package config

import (
"flag"
"fmt"
"github.com/blaize9/vuze-tools/utils"
"github.com/jinzhu/configor"
"path/filepath"
"strings"
"sync"
)

var (
DefaultConfigPath = "config/default_config.yml"
ConfigPath = "config/config.yml"
)

var config *Config
var once sync.Once

type Config struct {
Port int `json:"port" yaml:"port"`
Version string `json:"build_version" yaml:"build_version"`
LockFilename string `json:"lock_filename" yaml:"lock_filename"`
AzureusDirectory string `json:"azureus_directory" yaml:"azureus_directory"`
AzureusTorrentsDirectory string `json:"azureus_torrents_directory" yaml:"azureus_torrents_directory"`
AzureusDownloadsConfig string `json:"azureus_downloads_config" yaml:"azureus_downloads_config,omitempty"`
AzureusRecoverTempDirectory string `json:"azureus_recover_temp_directory" yaml:"azureus_recover_temp_directory,omitempty"`

SimpleRecoverWorkers int `json:"simple_recovery_workers" yaml:"simple_recovery_workers,omitempty"`
AdvancedRecoverMaxWorkers int `json:"advanced_recovery_max_workers" yaml:"advanced_recovery_max_workers,omitempty"`
AzureusBackupDirectories AzDirectories `yaml:"azureus_backup_directories,flow,omitempty"`

Environment string `json:"environment" yaml:"environment,omitempty"`
Log LogConfig `yaml:"log,flow,omitempty"`
}

type LogConfig struct {
AccessLogFilePath string `yaml:"access_log_filepath,omitempty"`
AccessLogFileExtension string `yaml:"access_log_fileextension,omitempty"`
AccessLogMaxSize int `yaml:"access_log_max_size,omitempty"`
AccessLogMaxBackups int `yaml:"access_log_max_backups,omitempty"`
AccessLogMaxAge int `yaml:"access_log_max_age,omitempty"`
ErrorLogFilePath string `yaml:"error_log_filepath,omitempty"`
ErrorLogFileExtension string `yaml:"error_log_fileextension,omitempty"`
ErrorLogMaxSize int `yaml:"error_log_max_size,omitempty"`
ErrorLogMaxBackups int `yaml:"error_log_max_backups,omitempty"`
ErrorLogMaxAge int `yaml:"error_log_max_age,omitempty"`
}

type AzDirectories []struct {
Directory string
}

func init() {
configor.Load(Get(), ConfigPath, DefaultConfigPath)
}

func Get() *Config {
once.Do(func() {
config = &Config{}
})
return config
}

func GetAzDownloadsConfig() string {
if filepath.Dir(Get().AzureusDownloadsConfig) == "." {
//file
return filepath.Join(Get().AzureusDirectory, Get().AzureusDownloadsConfig)
} else {
//filepath
return Get().AzureusDownloadsConfig
}
}

func GetAzTorrentsPath() string {
var path string
if Get().AzureusTorrentsDirectory == "" {
path = filepath.Join(Get().AzureusDirectory, "torrents")
} else {
path = filepath.Join(Get().AzureusDirectory, Get().AzureusTorrentsDirectory)
}
return path

}

func GetAzActivePath() string {
return filepath.Join(Get().AzureusDirectory, "active")

}

func GetAzRecoverPath() string {
var path string
if Get().AzureusRecoverTempDirectory == "" || Get().AzureusRecoverTempDirectory == "azureus-recover" {
path = filepath.Join(Get().AzureusDirectory, "../azureus-recover")
} else {
path = filepath.Join(Get().AzureusDirectory, Get().AzureusRecoverTempDirectory)
}

return path
}

func BindFLags() func() {
var backupdirs string
flag.StringVar(&Get().Environment, "env", Get().Environment, "Environment [DEV,PROD,PROD-STDOUT,PROD-JSON]")
flag.StringVar(&Get().AzureusDirectory, "azdir", Get().AzureusDirectory, "Directory that contains Azureus storage")
flag.StringVar(&Get().AzureusDownloadsConfig, "azconfig", Get().AzureusDownloadsConfig, "File or FilePath to the downloads.config")
flag.Parse()
if backupdirs != "" {
for _, dir := range strings.Split(backupdirs, ",") {
dir = strings.TrimSpace(dir)
if utils.DirExists(dir) {
Get().AzureusBackupDirectories = append(Get().AzureusBackupDirectories, struct{ Directory string }{Directory: dir})
} else {
fmt.Println("Backup directory %s does not exist!", dir)
}
}
}
return func() {
configor.Load(Get(), ConfigPath, DefaultConfigPath)
}
}
4 changes: 4 additions & 0 deletions config/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#Override default config values here
#azureus_backup_directories:
# -directory: /path/to/directory/that/contains/backups
# -directory: /path/to/other/directory/that/contains/backups
26 changes: 26 additions & 0 deletions config/default_config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
port: 9955
build_version: "0.9.0"
environment: PRODUCTION-STDOUT
lock_filename: "vuze-tools.lck"

azureus_directory: ""
azureus_torrents_directory: "torrents"
azureus_downloads_config: "downloads.config"
azureus_recover_temp_directory: "azureus-recover"
azureus_backup_directories:

simple_recovery_workers: 15
advanced_recovery_max_workers: 50

log:
access_log_filepath: log/access
access_log_fileextension: .txt
access_log_max_size: 5
access_log_max_backups: 7
access_log_max_age: 30
error_log_filepath: log/error
error_log_fileextension: .json
error_log_max_size: 10
error_log_max_backups: 7
error_log_max_age: 30

Loading

0 comments on commit 9656ef0

Please sign in to comment.