Skip to content

Commit

Permalink
Only touch when images, containers, layers save function called
Browse files Browse the repository at this point in the history
Signed-off-by: Dan Walsh <dwalsh@redhat.com>
  • Loading branch information
rhatdan committed Jun 2, 2017
1 parent 5c22817 commit c496eac
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 26 deletions.
1 change: 1 addition & 0 deletions containers.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ func (r *containerStore) Save() error {
if err != nil {
return err
}
defer r.Touch()
return ioutils.AtomicWriteFile(rpath, jdata, 0600)
}

Expand Down
1 change: 1 addition & 0 deletions images.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ func (r *imageStore) Save() error {
if err != nil {
return err
}
defer r.Touch()
return ioutils.AtomicWriteFile(rpath, jdata, 0600)
}

Expand Down
1 change: 1 addition & 0 deletions layers.go
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,7 @@ func (r *layerStore) Save() error {
if err := ioutils.AtomicWriteFile(rpath, jldata, 0600); err != nil {
return err
}
defer r.Touch()
return ioutils.AtomicWriteFile(mpath, jmdata, 0600)
}

Expand Down
26 changes: 0 additions & 26 deletions store.go
Original file line number Diff line number Diff line change
Expand Up @@ -621,13 +621,11 @@ func (s *store) PutLayer(id, parent string, names []string, mountLabel string, w

rlstore.Lock()
defer rlstore.Unlock()
defer rlstore.Touch()
if modified, err := rlstore.Modified(); modified || err != nil {
rlstore.Load()
}
rcstore.Lock()
defer rcstore.Unlock()
defer rcstore.Touch()
if modified, err := rcstore.Modified(); modified || err != nil {
rcstore.Load()
}
Expand Down Expand Up @@ -674,7 +672,6 @@ func (s *store) CreateImage(id string, names []string, layer, metadata string, o
}
ristore.Lock()
defer ristore.Unlock()
defer ristore.Touch()
if modified, err := ristore.Modified(); modified || err != nil {
ristore.Load()
}
Expand Down Expand Up @@ -709,7 +706,6 @@ func (s *store) CreateContainer(id string, names []string, image, layer, metadat

rlstore.Lock()
defer rlstore.Unlock()
defer rlstore.Touch()
if modified, err := rlstore.Modified(); modified || err != nil {
rlstore.Load()
}
Expand All @@ -720,7 +716,6 @@ func (s *store) CreateContainer(id string, names []string, image, layer, metadat
}
rcstore.Lock()
defer rcstore.Unlock()
defer rcstore.Touch()
if modified, err := rcstore.Modified(); modified || err != nil {
rcstore.Load()
}
Expand Down Expand Up @@ -785,15 +780,12 @@ func (s *store) SetMetadata(id, metadata string) error {
}

if rlstore.Exists(id) {
defer rlstore.Touch()
return rlstore.SetMetadata(id, metadata)
}
if ristore.Exists(id) {
defer ristore.Touch()
return ristore.SetMetadata(id, metadata)
}
if rcstore.Exists(id) {
defer rcstore.Touch()
return rcstore.SetMetadata(id, metadata)
}
return ErrNotAnID
Expand Down Expand Up @@ -1043,15 +1035,12 @@ func (s *store) SetNames(id string, names []string) error {
}

if rlstore.Exists(id) {
defer rlstore.Touch()
return rlstore.SetNames(id, deduped)
}
if ristore.Exists(id) {
defer ristore.Touch()
return ristore.SetNames(id, deduped)
}
if rcstore.Exists(id) {
defer rcstore.Touch()
return rcstore.SetNames(id, deduped)
}
return ErrLayerUnknown
Expand Down Expand Up @@ -1172,8 +1161,6 @@ func (s *store) DeleteLayer(id string) error {
}

if rlstore.Exists(id) {
defer rlstore.Touch()
defer rcstore.Touch()
if l, err := rlstore.Get(id); err != nil {
id = l.ID
}
Expand Down Expand Up @@ -1245,8 +1232,6 @@ func (s *store) DeleteImage(id string, commit bool) (layers []string, err error)
return nil, err
}
id = image.ID
defer rlstore.Touch()
defer ristore.Touch()
containers, err := rcstore.Containers()
if err != nil {
return nil, err
Expand Down Expand Up @@ -1360,8 +1345,6 @@ func (s *store) DeleteContainer(id string) error {
}

if rcstore.Exists(id) {
defer rlstore.Touch()
defer rcstore.Touch()
if container, err := rcstore.Get(id); err == nil {
if rlstore.Exists(container.LayerID) {
if err = rlstore.Delete(container.LayerID); err != nil {
Expand Down Expand Up @@ -1418,8 +1401,6 @@ func (s *store) Delete(id string) error {
}

if rcstore.Exists(id) {
defer rlstore.Touch()
defer rcstore.Touch()
if container, err := rcstore.Get(id); err == nil {
if rlstore.Exists(container.LayerID) {
if err = rlstore.Delete(container.LayerID); err != nil {
Expand All @@ -1443,11 +1424,9 @@ func (s *store) Delete(id string) error {
}
}
if ristore.Exists(id) {
defer ristore.Touch()
return ristore.Delete(id)
}
if rlstore.Exists(id) {
defer rlstore.Touch()
return rlstore.Delete(id)
}
return ErrLayerUnknown
Expand All @@ -1469,19 +1448,16 @@ func (s *store) Wipe() error {

rlstore.Lock()
defer rlstore.Unlock()
defer rlstore.Touch()
if modified, err := rlstore.Modified(); modified || err != nil {
rlstore.Load()
}
ristore.Lock()
defer ristore.Unlock()
defer ristore.Touch()
if modified, err := ristore.Modified(); modified || err != nil {
ristore.Load()
}
rcstore.Lock()
defer rcstore.Unlock()
defer rcstore.Touch()
if modified, err := rcstore.Modified(); modified || err != nil {
rcstore.Load()
}
Expand Down Expand Up @@ -1519,7 +1495,6 @@ func (s *store) Mount(id, mountLabel string) (string, error) {

rlstore.Lock()
defer rlstore.Unlock()
defer rlstore.Touch()
if modified, err := rlstore.Modified(); modified || err != nil {
rlstore.Load()
}
Expand Down Expand Up @@ -1547,7 +1522,6 @@ func (s *store) Unmount(id string) error {

rlstore.Lock()
defer rlstore.Unlock()
defer rlstore.Touch()
if modified, err := rlstore.Modified(); modified || err != nil {
rlstore.Load()
}
Expand Down

0 comments on commit c496eac

Please sign in to comment.