@@ -752,26 +752,22 @@ func (s *composeService) initialSync(ctx context.Context, project *types.Project
752752 dotGitIgnore ,
753753 triggerIgnore )
754754
755- pathsToCopy , err := s .initialSyncFiles (ctx , project , service , trigger , ignoreInitialSync )
755+ pathsToCopy , err := s .initialSyncFiles (service , trigger , ignoreInitialSync )
756756 if err != nil {
757757 return err
758758 }
759759
760760 return syncer .Sync (ctx , service .Name , pathsToCopy )
761761}
762762
763- // Syncs files from develop.watch.path if thy have been modified after the image has been created
763+ // Syncs files from develop.watch.path, ignoring bind-mounted and excluded paths.
764764//
765765//nolint:gocyclo
766- func (s * composeService ) initialSyncFiles (ctx context. Context , project * types. Project , service types.ServiceConfig , trigger types.Trigger , ignore watch.PathMatcher ) ([]* sync.PathMapping , error ) {
766+ func (s * composeService ) initialSyncFiles (service types.ServiceConfig , trigger types.Trigger , ignore watch.PathMatcher ) ([]* sync.PathMapping , error ) {
767767 fi , err := os .Stat (trigger .Path )
768768 if err != nil {
769769 return nil , err
770770 }
771- timeImageCreated , err := s .imageCreatedTime (ctx , project , service .Name )
772- if err != nil {
773- return nil , err
774- }
775771 var pathsToCopy []* sync.PathMapping
776772 switch mode := fi .Mode (); {
777773 case mode .IsDir ():
@@ -793,15 +789,7 @@ func (s *composeService) initialSyncFiles(ctx context.Context, project *types.Pr
793789 }
794790 return nil // skip file
795791 }
796- info , err := d .Info ()
797- if err != nil {
798- return err
799- }
800792 if ! d .IsDir () {
801- if info .ModTime ().Before (timeImageCreated ) {
802- // skip file if it was modified before image creation
803- return nil
804- }
805793 rel , err := filepath .Rel (trigger .Path , path )
806794 if err != nil {
807795 return err
@@ -816,7 +804,7 @@ func (s *composeService) initialSyncFiles(ctx context.Context, project *types.Pr
816804 })
817805 case mode .IsRegular ():
818806 // process file
819- if fi . ModTime (). After ( timeImageCreated ) && ! shouldIgnore (filepath .Base (trigger .Path ), ignore ) && ! checkIfPathAlreadyBindMounted (trigger .Path , service .Volumes ) {
807+ if ! shouldIgnore (filepath .Base (trigger .Path ), ignore ) && ! checkIfPathAlreadyBindMounted (trigger .Path , service .Volumes ) {
820808 pathsToCopy = append (pathsToCopy , & sync.PathMapping {
821809 HostPath : trigger .Path ,
822810 ContainerPath : trigger .Target ,
@@ -832,27 +820,3 @@ func shouldIgnore(name string, ignore watch.PathMatcher) bool {
832820 return shouldIgnore
833821}
834822
835- // gets the image creation time for a service
836- func (s * composeService ) imageCreatedTime (ctx context.Context , project * types.Project , serviceName string ) (time.Time , error ) {
837- res , err := s .apiClient ().ContainerList (ctx , client.ContainerListOptions {
838- All : true ,
839- Filters : projectFilter (project .Name ).Add ("label" , serviceFilter (serviceName )),
840- })
841- if err != nil {
842- return time .Now (), err
843- }
844- if len (res .Items ) == 0 {
845- return time .Now (), fmt .Errorf ("could not get created time for service's image" )
846- }
847-
848- img , err := s .apiClient ().ImageInspect (ctx , res .Items [0 ].ImageID )
849- if err != nil {
850- return time .Now (), err
851- }
852- // Need to get the oldest one?
853- timeCreated , err := time .Parse (time .RFC3339Nano , img .Created )
854- if err != nil {
855- return time .Now (), err
856- }
857- return timeCreated , nil
858- }
0 commit comments