Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Memorekall Member New
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Rekall
Memorekall Member New
Commits
92b05979
Commit
92b05979
authored
3 years ago
by
Loïs Poujade
Browse files
Options
Downloads
Patches
Plain Diff
Fix php
parent
975675a6
No related branches found
No related tags found
1 merge request
!93
Edit annotation picture
Pipeline
#1082
passed
3 years ago
Stage: test
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/Command/RekallProjectDuplicateImagesCommand.php
+30
-16
30 additions, 16 deletions
src/Command/RekallProjectDuplicateImagesCommand.php
with
30 additions
and
16 deletions
src/Command/RekallProjectDuplicateImagesCommand.php
+
30
−
16
View file @
92b05979
...
...
@@ -15,7 +15,7 @@ use Symfony\Component\HttpKernel\KernelInterface;
#
[
AsCommand
(
name
:
'rekall:project:duplicate-images'
,
description
:
'Duplicate each JPG/PNG/GIF file
, creating for each a corresponding rk_original_af7ef02e_<filename>.xyz file
'
,
description
:
'Duplicate each JPG/PNG/GIF file
to keep original separated from edited
'
,
)]
class
RekallProjectDuplicateImagesCommand
extends
Command
{
...
...
@@ -36,7 +36,9 @@ class RekallProjectDuplicateImagesCommand extends Command
$this
->
legacy_root
=
Path
::
join
(
$this
->
kernel
->
getProjectDir
(),
self
::
$LEGACY_DIRECTORY_NAME
);
}
protected
function
configure
():
void
{
}
protected
function
configure
():
void
{
}
protected
function
execute
(
InputInterface
$input
,
OutputInterface
$output
):
int
{
...
...
@@ -109,20 +111,32 @@ class RekallProjectDuplicateImagesCommand extends Command
string
$current_legacy_path
):
void
{
$output
->
writeln
(
"Updating project :
$current_legacy_path
"
);
$success
=
$failed
=
0
;
$success
=
0
;
$failed
=
0
;
foreach
(
glob
(
"
$current_legacy_path
/"
.
self
::
$IMG_GLOB
,
GLOB_BRACE
)
as
$filename
)
{
if
(
str_starts_with
(
$filename
,
$current_legacy_path
.
'/'
.
self
::
$ORIGINAL_FILE_PREPEND_WITH
))
$ar
=
glob
(
"
$current_legacy_path
/"
.
self
::
$IMG_GLOB
,
GLOB_BRACE
);
if
(
$ar
===
false
)
{
$output
->
writeln
(
"Failed to list projects images files for '
$current_legacy_path
'"
);
return
;
}
foreach
(
$ar
as
$filename
)
{
if
(
str_starts_with
(
$filename
,
$current_legacy_path
.
'/'
.
self
::
$ORIGINAL_FILE_PREPEND_WITH
))
{
continue
;
$target
=
str_replace
(
$current_legacy_path
.
'/'
,
$current_legacy_path
.
'/'
.
self
::
$ORIGINAL_FILE_PREPEND_WITH
,
$filename
);
}
$target
=
str_replace
(
$current_legacy_path
.
'/'
,
$current_legacy_path
.
'/'
.
self
::
$ORIGINAL_FILE_PREPEND_WITH
,
$filename
);
if
(
!
file_exists
(
$target
))
{
if
(
!
copy
(
$filename
,
$target
))
{
$output
->
writeln
(
"Failed to copy '
$filename
' to '
$target
'"
);
$failed
++
;
}
else
}
else
{
$success
++
;
}
}
}
$output
->
writeln
(
"Updated project :
$current_legacy_path
,
$success
files duplicated,
$failed
failed ---> DONE"
);
}
...
...
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