From a756b6a9e4d0ccdebfbe0bbdd89b28a125ba048d Mon Sep 17 00:00:00 2001 From: drigato Date: Mon, 7 Apr 2014 11:37:30 -0400 Subject: [PATCH 01/16] CC-5781: Upgrade script for new storage quota implementation Created skeleton for upgrade script --- .../upgrades/airtime-2.5.3/StorageQuotaUpgrade.php | 14 ++++++++++++++ .../upgrades/airtime-2.5.3/airtime-upgrade.php | 2 ++ 2 files changed, 16 insertions(+) create mode 100644 install_minimal/upgrades/airtime-2.5.3/StorageQuotaUpgrade.php diff --git a/install_minimal/upgrades/airtime-2.5.3/StorageQuotaUpgrade.php b/install_minimal/upgrades/airtime-2.5.3/StorageQuotaUpgrade.php new file mode 100644 index 000000000..9cfdd2d63 --- /dev/null +++ b/install_minimal/upgrades/airtime-2.5.3/StorageQuotaUpgrade.php @@ -0,0 +1,14 @@ + Date: Mon, 7 Apr 2014 11:58:58 -0400 Subject: [PATCH 02/16] Included upgrade folder path for 2.5.3 so Airtime can upgrade from older versions --- install_minimal/include/airtime-upgrade.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/install_minimal/include/airtime-upgrade.php b/install_minimal/include/airtime-upgrade.php index a85fbeed0..af9f971d4 100644 --- a/install_minimal/include/airtime-upgrade.php +++ b/install_minimal/include/airtime-upgrade.php @@ -102,4 +102,8 @@ if (strcmp($version, "2.5.1") < 0) { passthru("php --php-ini $SCRIPTPATH/../airtime-php.ini $SCRIPTPATH/../upgrades/airtime-2.5.1/airtime-upgrade.php"); pause(); } +if (strcmp($version, "2.5.3") < 0) { + passthru("php --php-ini $SCRIPTPATH/../airtime-php.ini $SCRIPTPATH/../upgrades/airtime-2.5.3/airtime-upgrade.php"); + pause(); +} echo "******************************* Upgrade Complete *******************************".PHP_EOL; From 770a51dccd8033b7ed8e3c75bceb47b2cd6b6ee0 Mon Sep 17 00:00:00 2001 From: drigato Date: Mon, 7 Apr 2014 12:14:49 -0400 Subject: [PATCH 03/16] Changed airtime version in necessary places --- CREDITS | 2 +- VERSION | 2 +- install_minimal/include/airtime-constants.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CREDITS b/CREDITS index 826799c99..b52ae289e 100644 --- a/CREDITS +++ b/CREDITS @@ -2,7 +2,7 @@ CREDITS ======= -Version 2.5.1 +Version 2.5.3 Albert Santoni (albert.santoni@sourcefabric.org) Role: Developer Team Lead diff --git a/VERSION b/VERSION index 5a1ef0b72..b7fd8620d 100644 --- a/VERSION +++ b/VERSION @@ -1,2 +1,2 @@ PRODUCT_ID=Airtime -PRODUCT_RELEASE=2.5.0 +PRODUCT_RELEASE=2.5.3 diff --git a/install_minimal/include/airtime-constants.php b/install_minimal/include/airtime-constants.php index 2a3bf95ee..fd6240bd2 100644 --- a/install_minimal/include/airtime-constants.php +++ b/install_minimal/include/airtime-constants.php @@ -1,3 +1,3 @@ Date: Mon, 7 Apr 2014 14:11:31 -0400 Subject: [PATCH 04/16] CC-5781: Upgrade script for new storage quota implementation --- .../upgrades/airtime-2.5.3/StorageQuotaUpgrade.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/install_minimal/upgrades/airtime-2.5.3/StorageQuotaUpgrade.php b/install_minimal/upgrades/airtime-2.5.3/StorageQuotaUpgrade.php index 9cfdd2d63..33731a2d3 100644 --- a/install_minimal/upgrades/airtime-2.5.3/StorageQuotaUpgrade.php +++ b/install_minimal/upgrades/airtime-2.5.3/StorageQuotaUpgrade.php @@ -9,6 +9,15 @@ class StorageQuotaUpgrade private static function setStorageUsage() { - + $musicDir = CcMusicDirsQuery::create() + ->filterByDbType('stor') + ->filterByDbExists(true) + ->findOne(); + $storPath = $musicDir->getDbDirectory(); + + $freeSpace = disk_free_space($storPath); + $totalSpace = disk_total_space($storPath); + + Application_Model_Preference::setDiskUsage($totalSpace - $freeSpace); } } \ No newline at end of file From c1cc3740f3839468c78a5fe879e527b45de0a1ec Mon Sep 17 00:00:00 2001 From: drigato Date: Mon, 7 Apr 2014 14:23:00 -0400 Subject: [PATCH 05/16] CC-5781: Upgrade script for new storage quota implementation Include propel library --- .../upgrades/airtime-2.5.3/StorageQuotaUpgrade.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/install_minimal/upgrades/airtime-2.5.3/StorageQuotaUpgrade.php b/install_minimal/upgrades/airtime-2.5.3/StorageQuotaUpgrade.php index 33731a2d3..b6c17b618 100644 --- a/install_minimal/upgrades/airtime-2.5.3/StorageQuotaUpgrade.php +++ b/install_minimal/upgrades/airtime-2.5.3/StorageQuotaUpgrade.php @@ -1,4 +1,6 @@ Date: Mon, 7 Apr 2014 14:40:08 -0400 Subject: [PATCH 06/16] CC-5781: Upgrade script for new storage quota implementation add propel to include path --- .../airtime-2.5.3/StorageQuotaUpgrade.php | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/install_minimal/upgrades/airtime-2.5.3/StorageQuotaUpgrade.php b/install_minimal/upgrades/airtime-2.5.3/StorageQuotaUpgrade.php index b6c17b618..6ac193e65 100644 --- a/install_minimal/upgrades/airtime-2.5.3/StorageQuotaUpgrade.php +++ b/install_minimal/upgrades/airtime-2.5.3/StorageQuotaUpgrade.php @@ -1,5 +1,19 @@ Date: Mon, 7 Apr 2014 14:49:23 -0400 Subject: [PATCH 07/16] CC-5781: Upgrade script for new storage quota implementation --- .../upgrades/airtime-2.5.3/StorageQuotaUpgrade.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/install_minimal/upgrades/airtime-2.5.3/StorageQuotaUpgrade.php b/install_minimal/upgrades/airtime-2.5.3/StorageQuotaUpgrade.php index 6ac193e65..97bb2a188 100644 --- a/install_minimal/upgrades/airtime-2.5.3/StorageQuotaUpgrade.php +++ b/install_minimal/upgrades/airtime-2.5.3/StorageQuotaUpgrade.php @@ -10,10 +10,10 @@ set_include_path(implode(PATH_SEPARATOR, array( realpath(APPLICATION_PATH . '/../library') ))); -/*set_include_path(implode(PATH_SEPARATOR, array( +set_include_path(implode(PATH_SEPARATOR, array( get_include_path(), realpath(APPLICATION_PATH . '/../library/propel/runtime/lib') -)));*/ +))); class StorageQuotaUpgrade { From 10778fd88d2ef70ee06963959998e63a848bb41d Mon Sep 17 00:00:00 2001 From: drigato Date: Mon, 7 Apr 2014 14:52:55 -0400 Subject: [PATCH 08/16] CC-5781: Upgrade script for new storage quota implementation --- install_minimal/upgrades/airtime-2.5.3/StorageQuotaUpgrade.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/install_minimal/upgrades/airtime-2.5.3/StorageQuotaUpgrade.php b/install_minimal/upgrades/airtime-2.5.3/StorageQuotaUpgrade.php index 97bb2a188..dbef72e41 100644 --- a/install_minimal/upgrades/airtime-2.5.3/StorageQuotaUpgrade.php +++ b/install_minimal/upgrades/airtime-2.5.3/StorageQuotaUpgrade.php @@ -15,6 +15,9 @@ set_include_path(implode(PATH_SEPARATOR, array( realpath(APPLICATION_PATH . '/../library/propel/runtime/lib') ))); +//Propel classes. +set_include_path(APPLICATION_PATH . '/models' . PATH_SEPARATOR . get_include_path()); + class StorageQuotaUpgrade { public static function startUpgrade() From 6cd1ebb5eae3d2167e3048e89d9089a983113d12 Mon Sep 17 00:00:00 2001 From: drigato Date: Mon, 7 Apr 2014 14:59:58 -0400 Subject: [PATCH 09/16] CC-5781: Upgrade script for new storage quota implementation --- .../upgrades/airtime-2.5.3/StorageQuotaUpgrade.php | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/install_minimal/upgrades/airtime-2.5.3/StorageQuotaUpgrade.php b/install_minimal/upgrades/airtime-2.5.3/StorageQuotaUpgrade.php index dbef72e41..56a792f5a 100644 --- a/install_minimal/upgrades/airtime-2.5.3/StorageQuotaUpgrade.php +++ b/install_minimal/upgrades/airtime-2.5.3/StorageQuotaUpgrade.php @@ -10,14 +10,11 @@ set_include_path(implode(PATH_SEPARATOR, array( realpath(APPLICATION_PATH . '/../library') ))); -set_include_path(implode(PATH_SEPARATOR, array( - get_include_path(), - realpath(APPLICATION_PATH . '/../library/propel/runtime/lib') -))); - //Propel classes. set_include_path(APPLICATION_PATH . '/models' . PATH_SEPARATOR . get_include_path()); +require_once 'CcMusicDirsQuery.php'; + class StorageQuotaUpgrade { public static function startUpgrade() From b61fae77b3163caba3b05f56ab11715fcd45a0e7 Mon Sep 17 00:00:00 2001 From: drigato Date: Mon, 7 Apr 2014 15:04:54 -0400 Subject: [PATCH 10/16] CC-5781: Upgrade script for new storage quota implementation --- install_minimal/upgrades/airtime-2.5.3/StorageQuotaUpgrade.php | 1 + 1 file changed, 1 insertion(+) diff --git a/install_minimal/upgrades/airtime-2.5.3/StorageQuotaUpgrade.php b/install_minimal/upgrades/airtime-2.5.3/StorageQuotaUpgrade.php index 56a792f5a..99ee2e8dd 100644 --- a/install_minimal/upgrades/airtime-2.5.3/StorageQuotaUpgrade.php +++ b/install_minimal/upgrades/airtime-2.5.3/StorageQuotaUpgrade.php @@ -12,6 +12,7 @@ set_include_path(implode(PATH_SEPARATOR, array( //Propel classes. set_include_path(APPLICATION_PATH . '/models' . PATH_SEPARATOR . get_include_path()); +set_include_path(APPLICATION_PATH . '/models/airtime' . PATH_SEPARATOR . get_include_path()); require_once 'CcMusicDirsQuery.php'; From 54868c9f6eb317c2165fdf7d5b3ae95950125b25 Mon Sep 17 00:00:00 2001 From: drigato Date: Mon, 7 Apr 2014 15:07:42 -0400 Subject: [PATCH 11/16] CC-5781: Upgrade script for new storage quota implementation --- install_minimal/upgrades/airtime-2.5.3/StorageQuotaUpgrade.php | 1 + 1 file changed, 1 insertion(+) diff --git a/install_minimal/upgrades/airtime-2.5.3/StorageQuotaUpgrade.php b/install_minimal/upgrades/airtime-2.5.3/StorageQuotaUpgrade.php index 99ee2e8dd..0bfe3df1e 100644 --- a/install_minimal/upgrades/airtime-2.5.3/StorageQuotaUpgrade.php +++ b/install_minimal/upgrades/airtime-2.5.3/StorageQuotaUpgrade.php @@ -12,6 +12,7 @@ set_include_path(implode(PATH_SEPARATOR, array( //Propel classes. set_include_path(APPLICATION_PATH . '/models' . PATH_SEPARATOR . get_include_path()); +set_include_path(APPLICATION_PATH . '/models/om' . PATH_SEPARATOR . get_include_path()); set_include_path(APPLICATION_PATH . '/models/airtime' . PATH_SEPARATOR . get_include_path()); require_once 'CcMusicDirsQuery.php'; From aa531c882f4412d1e625af8ecaa5d3e0cc91cff0 Mon Sep 17 00:00:00 2001 From: drigato Date: Mon, 7 Apr 2014 15:16:32 -0400 Subject: [PATCH 12/16] CC-5781: Upgrade script for new storage quota implementation --- .../upgrades/airtime-2.5.3/StorageQuotaUpgrade.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/install_minimal/upgrades/airtime-2.5.3/StorageQuotaUpgrade.php b/install_minimal/upgrades/airtime-2.5.3/StorageQuotaUpgrade.php index 0bfe3df1e..d039df381 100644 --- a/install_minimal/upgrades/airtime-2.5.3/StorageQuotaUpgrade.php +++ b/install_minimal/upgrades/airtime-2.5.3/StorageQuotaUpgrade.php @@ -12,10 +12,11 @@ set_include_path(implode(PATH_SEPARATOR, array( //Propel classes. set_include_path(APPLICATION_PATH . '/models' . PATH_SEPARATOR . get_include_path()); -set_include_path(APPLICATION_PATH . '/models/om' . PATH_SEPARATOR . get_include_path()); -set_include_path(APPLICATION_PATH . '/models/airtime' . PATH_SEPARATOR . get_include_path()); +#set_include_path(APPLICATION_PATH . '/models/om' . PATH_SEPARATOR . get_include_path()); +#set_include_path(APPLICATION_PATH . '/models/airtime' . PATH_SEPARATOR . get_include_path()); require_once 'CcMusicDirsQuery.php'; +require_once 'BaseCcMusicDirsQuery.php'; class StorageQuotaUpgrade { From c18c4da629dba56976a7dd5f1d15f33c45935964 Mon Sep 17 00:00:00 2001 From: drigato Date: Mon, 7 Apr 2014 15:18:33 -0400 Subject: [PATCH 13/16] CC-5781: Upgrade script for new storage quota implementation --- .../upgrades/airtime-2.5.3/StorageQuotaUpgrade.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/install_minimal/upgrades/airtime-2.5.3/StorageQuotaUpgrade.php b/install_minimal/upgrades/airtime-2.5.3/StorageQuotaUpgrade.php index d039df381..43c2e124c 100644 --- a/install_minimal/upgrades/airtime-2.5.3/StorageQuotaUpgrade.php +++ b/install_minimal/upgrades/airtime-2.5.3/StorageQuotaUpgrade.php @@ -12,8 +12,8 @@ set_include_path(implode(PATH_SEPARATOR, array( //Propel classes. set_include_path(APPLICATION_PATH . '/models' . PATH_SEPARATOR . get_include_path()); -#set_include_path(APPLICATION_PATH . '/models/om' . PATH_SEPARATOR . get_include_path()); -#set_include_path(APPLICATION_PATH . '/models/airtime' . PATH_SEPARATOR . get_include_path()); +set_include_path(APPLICATION_PATH . '/models/airtime' . PATH_SEPARATOR . get_include_path()); +set_include_path(APPLICATION_PATH . '/models/om' . PATH_SEPARATOR . get_include_path()); require_once 'CcMusicDirsQuery.php'; require_once 'BaseCcMusicDirsQuery.php'; From 70e660e7dae1bac300a228e3b401015811dc33ce Mon Sep 17 00:00:00 2001 From: drigato Date: Mon, 7 Apr 2014 15:26:56 -0400 Subject: [PATCH 14/16] CC-5781: Upgrade script for new storage quota implementation --- .../upgrades/airtime-2.5.3/StorageQuotaUpgrade.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/install_minimal/upgrades/airtime-2.5.3/StorageQuotaUpgrade.php b/install_minimal/upgrades/airtime-2.5.3/StorageQuotaUpgrade.php index 43c2e124c..8574d4bee 100644 --- a/install_minimal/upgrades/airtime-2.5.3/StorageQuotaUpgrade.php +++ b/install_minimal/upgrades/airtime-2.5.3/StorageQuotaUpgrade.php @@ -10,13 +10,19 @@ set_include_path(implode(PATH_SEPARATOR, array( realpath(APPLICATION_PATH . '/../library') ))); +/*set_include_path(implode(PATH_SEPARATOR, array( + get_include_path(), + realpath(APPLICATION_PATH . '/../library/propel/runtime/lib') +)));*/ + //Propel classes. set_include_path(APPLICATION_PATH . '/models' . PATH_SEPARATOR . get_include_path()); set_include_path(APPLICATION_PATH . '/models/airtime' . PATH_SEPARATOR . get_include_path()); set_include_path(APPLICATION_PATH . '/models/om' . PATH_SEPARATOR . get_include_path()); +require_once 'propel/runtime/lib/Propel.php'; require_once 'CcMusicDirsQuery.php'; -require_once 'BaseCcMusicDirsQuery.php'; +#require_once 'BaseCcMusicDirsQuery.php'; class StorageQuotaUpgrade { From b8b913ff68a47f68d4ade640b7781b4744740a11 Mon Sep 17 00:00:00 2001 From: Albert Santoni Date: Mon, 7 Apr 2014 16:19:44 -0400 Subject: [PATCH 15/16] CC-5709: Airtime Analyzer * Fixed daemonization stuff for upstart * Adding missing unit test files --- .../airtime_analyzer/bin/airtime_analyzer | 2 +- .../install/upstart/airtime_analyzer.conf | 3 +- .../airtime_analyzer/tests/analyzer_tests.py | 13 ++ .../tests/filemover_analyzer_tests.py | 112 ++++++++++++++++++ 4 files changed, 127 insertions(+), 3 deletions(-) create mode 100644 python_apps/airtime_analyzer/tests/analyzer_tests.py create mode 100644 python_apps/airtime_analyzer/tests/filemover_analyzer_tests.py diff --git a/python_apps/airtime_analyzer/bin/airtime_analyzer b/python_apps/airtime_analyzer/bin/airtime_analyzer index 8b45e775c..c74ad044c 100755 --- a/python_apps/airtime_analyzer/bin/airtime_analyzer +++ b/python_apps/airtime_analyzer/bin/airtime_analyzer @@ -1,6 +1,6 @@ +#!/usr/bin/env python """Runs the airtime_analyzer application. """ -#!/usr/bin/env python import daemon import argparse diff --git a/python_apps/airtime_analyzer/install/upstart/airtime_analyzer.conf b/python_apps/airtime_analyzer/install/upstart/airtime_analyzer.conf index a4837e50d..03bba725c 100644 --- a/python_apps/airtime_analyzer/install/upstart/airtime_analyzer.conf +++ b/python_apps/airtime_analyzer/install/upstart/airtime_analyzer.conf @@ -4,8 +4,7 @@ author "help@sourcefabric.org" start on runlevel [2345] stop on runlevel [!2345] -expect daemon respawn -exec sudo -u www-data airtime_analyzer --daemon +exec su www-data -c "airtime_analyzer" diff --git a/python_apps/airtime_analyzer/tests/analyzer_tests.py b/python_apps/airtime_analyzer/tests/analyzer_tests.py new file mode 100644 index 000000000..fc6fbc684 --- /dev/null +++ b/python_apps/airtime_analyzer/tests/analyzer_tests.py @@ -0,0 +1,13 @@ +from nose.tools import * +from airtime_analyzer.analyzer import Analyzer + +def setup(): + pass + +def teardown(): + pass + +@raises(NotImplementedError) +def test_analyze(): + abstract_analyzer = Analyzer() + abstract_analyzer.analyze(u'foo', dict()) diff --git a/python_apps/airtime_analyzer/tests/filemover_analyzer_tests.py b/python_apps/airtime_analyzer/tests/filemover_analyzer_tests.py new file mode 100644 index 000000000..7591442c0 --- /dev/null +++ b/python_apps/airtime_analyzer/tests/filemover_analyzer_tests.py @@ -0,0 +1,112 @@ +from nose.tools import * +import os +import shutil +import multiprocessing +import Queue +import time +import mock +from pprint import pprint +from airtime_analyzer.filemover_analyzer import FileMoverAnalyzer + +DEFAULT_AUDIO_FILE = u'tests/test_data/44100Hz-16bit-mono.mp3' +DEFAULT_IMPORT_DEST = u'Test Artist/Test Album/44100Hz-16bit-mono.mp3' + +def setup(): + pass + +def teardown(): + pass + +@raises(Exception) +def test_dont_use_analyze(): + FileMoverAnalyzer.analyze(u'foo', dict()) + +@raises(TypeError) +def test_move_wrong_string_param1(): + FileMoverAnalyzer.move('', u'', u'', dict()) + +@raises(TypeError) +def test_move_wrong_string_param2(): + FileMoverAnalyzer.move(u'', '', u'', dict()) + +@raises(TypeError) +def test_move_wrong_string_param3(): + FileMoverAnalyzer.move(u'', u'', '', dict()) + +@raises(TypeError) +def test_move_wrong_dict_param(): + FileMoverAnalyzer.move(u'', u'', u'', 12345) + +def test_basic(): + filename = os.path.basename(DEFAULT_AUDIO_FILE) + FileMoverAnalyzer.move(DEFAULT_AUDIO_FILE, u'.', filename, dict()) + #Move the file back + shutil.move("./" + filename, DEFAULT_AUDIO_FILE) + assert os.path.exists(DEFAULT_AUDIO_FILE) + +def test_basic_samefile(): + filename = os.path.basename(DEFAULT_AUDIO_FILE) + FileMoverAnalyzer.move(DEFAULT_AUDIO_FILE, u'tests/test_data', filename, dict()) + assert os.path.exists(DEFAULT_AUDIO_FILE) + +def test_duplicate_file(): + filename = os.path.basename(DEFAULT_AUDIO_FILE) + #Import the file once + FileMoverAnalyzer.move(DEFAULT_AUDIO_FILE, u'.', filename, dict()) + #Copy it back to the original location + shutil.copy("./" + filename, DEFAULT_AUDIO_FILE) + #Import it again. It shouldn't overwrite the old file and instead create a new + metadata = dict() + metadata = FileMoverAnalyzer.move(DEFAULT_AUDIO_FILE, u'.', filename, metadata) + #Cleanup: move the file (eg. 44100Hz-16bit-mono.mp3) back + shutil.move("./" + filename, DEFAULT_AUDIO_FILE) + #Remove the renamed duplicate, eg. 44100Hz-16bit-mono_03-26-2014-11-58.mp3 + os.remove(metadata["full_path"]) + assert os.path.exists(DEFAULT_AUDIO_FILE) + +''' If you import three copies of the same file, the behaviour is: + - The filename is of the first file preserved. + - The filename of the second file has the timestamp attached to it. + - The filename of the third file has a UUID placed after the timestamp, but ONLY IF + it's imported within 1 second of the second file (ie. if the timestamp is the same). +''' +def test_double_duplicate_files(): + # Here we use mock to patch out the time.localtime() function so that it + # always returns the same value. This allows us to consistently simulate this test cases + # where the last two of the three files are imported at the same time as the timestamp. + with mock.patch('airtime_analyzer.filemover_analyzer.time') as mock_time: + mock_time.localtime.return_value = time.localtime()#date(2010, 10, 8) + mock_time.side_effect = lambda *args, **kw: time(*args, **kw) + + filename = os.path.basename(DEFAULT_AUDIO_FILE) + #Import the file once + FileMoverAnalyzer.move(DEFAULT_AUDIO_FILE, u'.', filename, dict()) + #Copy it back to the original location + shutil.copy("./" + filename, DEFAULT_AUDIO_FILE) + #Import it again. It shouldn't overwrite the old file and instead create a new + first_dup_metadata = dict() + first_dup_metadata = FileMoverAnalyzer.move(DEFAULT_AUDIO_FILE, u'.', filename, + first_dup_metadata) + #Copy it back again! + shutil.copy("./" + filename, DEFAULT_AUDIO_FILE) + #Reimport for the third time, which should have the same timestamp as the second one + #thanks to us mocking out time.localtime() + second_dup_metadata = dict() + second_dup_metadata = FileMoverAnalyzer.move(DEFAULT_AUDIO_FILE, u'.', filename, + second_dup_metadata) + #Cleanup: move the file (eg. 44100Hz-16bit-mono.mp3) back + shutil.move("./" + filename, DEFAULT_AUDIO_FILE) + #Remove the renamed duplicate, eg. 44100Hz-16bit-mono_03-26-2014-11-58.mp3 + os.remove(first_dup_metadata["full_path"]) + os.remove(second_dup_metadata["full_path"]) + assert os.path.exists(DEFAULT_AUDIO_FILE) + +@raises(OSError) +def test_bad_permissions_destination_dir(): + filename = os.path.basename(DEFAULT_AUDIO_FILE) + dest_dir = u'/var/foobar' + FileMoverAnalyzer.move(DEFAULT_AUDIO_FILE, dest_dir, filename, dict()) + #Move the file back + shutil.move(os.path.join(dest_dir, filename), DEFAULT_AUDIO_FILE) + assert os.path.exists(DEFAULT_AUDIO_FILE) + From 3adaf8e3706b7c1af92b83a946c4918e1b8cba6a Mon Sep 17 00:00:00 2001 From: drigato Date: Tue, 8 Apr 2014 10:32:27 -0400 Subject: [PATCH 16/16] CC-5781: Upgrade script for new storage quota implementation Upgrade script for local installs SAAS requires a different script --- .../airtime-2.5.3/StorageQuotaUpgrade.php | 30 ++----------------- .../airtime-2.5.3/airtime-upgrade.php | 6 ++++ 2 files changed, 9 insertions(+), 27 deletions(-) diff --git a/install_minimal/upgrades/airtime-2.5.3/StorageQuotaUpgrade.php b/install_minimal/upgrades/airtime-2.5.3/StorageQuotaUpgrade.php index 8574d4bee..b734cc8c4 100644 --- a/install_minimal/upgrades/airtime-2.5.3/StorageQuotaUpgrade.php +++ b/install_minimal/upgrades/airtime-2.5.3/StorageQuotaUpgrade.php @@ -1,29 +1,5 @@ filterByDbType('stor') - ->filterByDbExists(true) + ->filterByType('stor') + ->filterByExists(true) ->findOne(); - $storPath = $musicDir->getDbDirectory(); + $storPath = $musicDir->getDirectory(); $freeSpace = disk_free_space($storPath); $totalSpace = disk_total_space($storPath); diff --git a/install_minimal/upgrades/airtime-2.5.3/airtime-upgrade.php b/install_minimal/upgrades/airtime-2.5.3/airtime-upgrade.php index 31792eb7a..09ecd7ed2 100644 --- a/install_minimal/upgrades/airtime-2.5.3/airtime-upgrade.php +++ b/install_minimal/upgrades/airtime-2.5.3/airtime-upgrade.php @@ -1,5 +1,11 @@