Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
our_own_cloud_project
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
die_coolen_jungs
our_own_cloud_project
Commits
64b68f24
Commit
64b68f24
authored
13 years ago
by
Robin Appelman
Browse files
Options
Downloads
Patches
Plain Diff
correctly update the collection when music files are moved around
parent
6c2b2240
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
apps/media/ajax/api.php
+1
-1
1 addition, 1 deletion
apps/media/ajax/api.php
apps/media/lib_collection.php
+16
-4
16 additions, 4 deletions
apps/media/lib_collection.php
apps/media/lib_media.php
+9
-0
9 additions, 0 deletions
apps/media/lib_media.php
with
26 additions
and
5 deletions
apps/media/ajax/api.php
+
1
−
1
View file @
64b68f24
...
...
@@ -134,7 +134,7 @@ if($arguments['action']){
}
}
function
findMusic
(
$path
=
'
/
'
){
function
findMusic
(
$path
=
''
){
$music
=
array
();
$dh
=
OC_Filesystem
::
opendir
(
$path
);
if
(
$dh
){
...
...
This diff is collapsed.
Click to expand it.
apps/media/lib_collection.php
+
16
−
4
View file @
64b68f24
...
...
@@ -251,10 +251,12 @@ class OC_MEDIA_COLLECTION{
if
(
$name
==
''
or
$path
==
''
){
return
0
;
}
$uid
=
$_SESSION
[
'user_id'
]
;
$uid
=
OC_User
::
getUser
()
;
//check if the song is already in the database
$songId
=
self
::
getSongId
(
$name
,
$artist
,
$album
);
if
(
$songId
!=
0
){
$songInfo
=
self
::
getSong
(
$songId
);
self
::
moveSong
(
$songInfo
[
'song_path'
],
$path
);
return
$songId
;
}
else
{
if
(
!
isset
(
self
::
$queries
[
'addsong'
])){
...
...
@@ -357,13 +359,23 @@ class OC_MEDIA_COLLECTION{
*/
public
static
function
getSongByPath
(
$path
){
$query
=
OC_DB
::
prepare
(
"SELECT song_id FROM *PREFIX*media_songs WHERE song_path = ?"
);
$result
=
$query
->
execute
(
array
(
$path
))
->
fetchAll
()
;
if
(
count
(
$result
)
>
0
){
return
$r
esult
[
0
]
[
'song_id'
];
$result
=
$query
->
execute
(
array
(
$path
));
if
(
$row
=
$result
->
fetchRow
()
){
return
$r
ow
[
'song_id'
];
}
else
{
return
0
;
}
}
/**
* set the path of a song
* @param string $oldPath
* @param string $newPath
*/
public
static
function
moveSong
(
$oldPath
,
$newPath
){
$query
=
OC_DB
::
prepare
(
"UPDATE *PREFIX*media_songs SET song_path = ? WHERE song_path = ?"
);
$query
->
execute
(
array
(
$newPath
,
$oldPath
));
}
}
?>
\ No newline at end of file
This diff is collapsed.
Click to expand it.
apps/media/lib_media.php
+
9
−
0
View file @
64b68f24
...
...
@@ -30,6 +30,9 @@ OC_Hook::connect('OC_Filesystem','post_write','OC_MEDIA','updateFile');
//listen for file deletions to clean the database if a song is deleted
OC_Hook
::
connect
(
'OC_Filesystem'
,
'delete'
,
'OC_MEDIA'
,
'deleteFile'
);
//list for file moves to update the database
OC_Hook
::
connect
(
'OC_Filesystem'
,
'post_rename'
,
'OC_MEDIA'
,
'moveFile'
);
class
OC_MEDIA
{
/**
* get the sha256 hash of the password needed for ampache
...
...
@@ -61,6 +64,7 @@ class OC_MEDIA{
$path
=
substr
(
$path
,
1
);
}
$path
=
'/'
.
$path
;
error_log
(
"
$path
was updated"
);
OC_MEDIA_SCANNER
::
scanFile
(
$path
);
}
...
...
@@ -72,6 +76,11 @@ class OC_MEDIA{
require_once
'lib_collection.php'
;
OC_MEDIA_COLLECTION
::
deleteSongByPath
(
$path
);
}
public
static
function
moveFile
(
$params
){
require_once
'lib_collection.php'
;
OC_MEDIA_COLLECTION
::
moveSong
(
$params
[
'oldpath'
],
$params
[
'newpath'
]);
}
}
class
OC_MediaSearchProvider
extends
OC_Search_Provider
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment